Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/AdapterManagerTracker.java44
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/ExtensionRegistryRunnable.java64
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/OptionalCodeSafeRunnable.java21
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/Activator.java72
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/internal/core/sharedobject/Activator.java40
-rw-r--r--framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java182
6 files changed, 196 insertions, 227 deletions
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/AdapterManagerTracker.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/AdapterManagerTracker.java
new file mode 100644
index 000000000..29d12a311
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/AdapterManagerTracker.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Composent, Inc. and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.util;
+
+import org.eclipse.core.runtime.*;
+import org.eclipse.ecf.internal.core.identity.Activator;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+/**
+ * @since 3.3
+ */
+public class AdapterManagerTracker extends ServiceTracker {
+
+ public AdapterManagerTracker(BundleContext context,
+ ServiceTrackerCustomizer customizer) {
+ super(context, IAdapterManager.class.getName(), customizer);
+ }
+
+ public AdapterManagerTracker(BundleContext context) {
+ this(context, null);
+ }
+
+ public IAdapterManager getAdapterManager() {
+ IAdapterManager adapterManager = (IAdapterManager) getService();
+ // Then, if the service isn't there, try to get from Platform class via
+ // PlatformHelper class
+ if (adapterManager == null)
+ adapterManager = PlatformHelper.getPlatformAdapterManager();
+ if (adapterManager == null)
+ Activator.getDefault().log(
+ new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ IStatus.ERROR, "Cannot get adapter manager", null)); //$NON-NLS-1$
+ return adapterManager;
+ }
+
+}
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/ExtensionRegistryRunnable.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/ExtensionRegistryRunnable.java
new file mode 100644
index 000000000..ca82a0987
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/ExtensionRegistryRunnable.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Composent, Inc. and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.util;
+
+import org.eclipse.core.runtime.*;
+import org.eclipse.ecf.internal.core.identity.Activator;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * @since 3.3
+ */
+public abstract class ExtensionRegistryRunnable implements ISafeRunnable {
+
+ private BundleContext context;
+
+ public ExtensionRegistryRunnable(BundleContext ctxt) {
+ this.context = ctxt;
+ }
+
+ protected void runWithoutRegistry() throws Exception {
+ // by default do nothing
+ }
+
+ protected abstract void runWithRegistry(IExtensionRegistry registry)
+ throws Exception;
+
+ protected void logWarning(Throwable exception) {
+ Activator a = Activator.getDefault();
+ if (a != null)
+ a.log(new Status(IStatus.WARNING, Activator.PLUGIN_ID,
+ IStatus.WARNING, "Warning: code cannot be run", exception)); //$NON-NLS-1$
+ }
+
+ public void run() throws Exception {
+ try {
+ runWithRegistry(getExtensionRegistry());
+ } catch (NoClassDefFoundError e) {
+ runWithoutRegistry();
+ }
+ }
+
+ private IExtensionRegistry getExtensionRegistry() {
+ if (context == null)
+ return null;
+ ServiceTracker extensionRegistryTracker = new ServiceTracker(context,
+ IExtensionRegistry.class.getName(), null);
+ extensionRegistryTracker.open();
+ IExtensionRegistry result = (IExtensionRegistry) extensionRegistryTracker
+ .getService();
+ extensionRegistryTracker.close();
+ return result;
+ }
+
+ public void handleException(Throwable exception) {
+ logWarning(exception);
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/OptionalCodeSafeRunnable.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/OptionalCodeSafeRunnable.java
deleted file mode 100644
index 463eb2bee..000000000
--- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/OptionalCodeSafeRunnable.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.eclipse.ecf.core.util;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.ecf.internal.core.identity.Activator;
-
-/**
- * @since 3.3
- */
-public abstract class OptionalCodeSafeRunnable implements ISafeRunnable {
-
- public void handleException(Throwable exception) {
- Activator a = Activator.getDefault();
- if (a != null)
- a.log(new Status(IStatus.WARNING, Activator.PLUGIN_ID,
- IStatus.WARNING,
- "Warning: optional code cannot be run", exception)); //$NON-NLS-1$
- }
-
- public abstract void run() throws Exception;
-
-}
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/Activator.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/Activator.java
index b4973022a..a4e5f21ff 100644
--- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/Activator.java
+++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/Activator.java
@@ -45,15 +45,13 @@ public class Activator implements BundleActivator {
private ServiceRegistration idFactoryServiceRegistration;
- private ServiceTracker extensionRegistryTracker;
-
private ServiceTracker debugOptionsTracker;
private ServiceTracker logServiceTracker;
private LogService logService;
- private ServiceTracker adapterManagerTracker;
+ private AdapterManagerTracker adapterManagerTracker;
// This is object rather than typed to avoid referencing the
// IRegistryChangedListener class directly
@@ -64,21 +62,10 @@ public class Activator implements BundleActivator {
return null;
// First, try to get the adapter manager via
if (adapterManagerTracker == null) {
- adapterManagerTracker = new ServiceTracker(this.context,
- IAdapterManager.class.getName(), null);
+ adapterManagerTracker = new AdapterManagerTracker(this.context);
adapterManagerTracker.open();
}
- IAdapterManager adapterManager = (IAdapterManager) adapterManagerTracker
- .getService();
- // Then, if the service isn't there, try to get from Platform class via
- // PlatformHelper class
- if (adapterManager == null)
- adapterManager = PlatformHelper.getPlatformAdapterManager();
- if (adapterManager == null)
- getDefault().log(
- new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR,
- "Cannot get adapter manager", null)); //$NON-NLS-1$
- return adapterManager;
+ return adapterManagerTracker.getAdapterManager();
}
/**
@@ -88,17 +75,6 @@ public class Activator implements BundleActivator {
// public null constructor
}
- synchronized IExtensionRegistry getExtensionRegistry() {
- if (this.context == null)
- return null;
- if (extensionRegistryTracker == null) {
- extensionRegistryTracker = new ServiceTracker(context,
- IExtensionRegistry.class.getName(), null);
- extensionRegistryTracker.open();
- }
- return (IExtensionRegistry) extensionRegistryTracker.getService();
- }
-
public synchronized DebugOptions getDebugOptions() {
if (context == null)
return null;
@@ -123,10 +99,10 @@ public class Activator implements BundleActivator {
idFactoryServiceRegistration = context.registerService(
IIDFactory.class.getName(), IDFactory.getDefault(), null);
- SafeRunner.run(new OptionalCodeSafeRunnable() {
- public void run() throws Exception {
- final IExtensionRegistry reg = getExtensionRegistry();
- if (reg != null) {
+ SafeRunner.run(new ExtensionRegistryRunnable(ctxt) {
+ protected void runWithRegistry(IExtensionRegistry registry)
+ throws Exception {
+ if (registry != null) {
registryManager = new IRegistryChangeListener() {
public void registryChanged(IRegistryChangeEvent event) {
final IExtensionDelta delta[] = event
@@ -148,7 +124,7 @@ public class Activator implements BundleActivator {
}
}
};
- reg.addRegistryChangeListener((IRegistryChangeListener) registryManager);
+ registry.addRegistryChangeListener((IRegistryChangeListener) registryManager);
}
}
});
@@ -278,12 +254,11 @@ public class Activator implements BundleActivator {
public void setupNamespaceExtensionPoint() {
if (context != null)
setupNamespaceServices();
- SafeRunner.run(new OptionalCodeSafeRunnable() {
- public void run() throws Exception {
- // Process extension points
- final IExtensionRegistry reg = getExtensionRegistry();
- if (reg != null) {
- final IExtensionPoint extensionPoint = reg
+ SafeRunner.run(new ExtensionRegistryRunnable(context) {
+ protected void runWithRegistry(IExtensionRegistry registry)
+ throws Exception {
+ if (registry != null) {
+ final IExtensionPoint extensionPoint = registry
.getExtensionPoint(NAMESPACE_EPOINT);
if (extensionPoint == null)
return;
@@ -304,11 +279,9 @@ public class Activator implements BundleActivator {
public Object addingService(ServiceReference reference) {
Namespace ns = (Namespace) context
.getService(reference);
- if (ns != null) {
+ if (ns != null && ns.getName() != null)
IDFactory.addNamespace0(ns);
- return ns;
- }
- return null;
+ return ns;
}
public void modifiedService(ServiceReference reference,
@@ -331,14 +304,13 @@ public class Activator implements BundleActivator {
* org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext ctxt) throws Exception {
- SafeRunner.run(new OptionalCodeSafeRunnable() {
- public void run() throws Exception {
- final IExtensionRegistry reg = getExtensionRegistry();
- if (reg != null)
- reg.removeRegistryChangeListener((IRegistryChangeListener) registryManager);
+ SafeRunner.run(new ExtensionRegistryRunnable(ctxt) {
+ protected void runWithRegistry(IExtensionRegistry registry)
+ throws Exception {
+ if (registry != null)
+ registry.removeRegistryChangeListener((IRegistryChangeListener) registryManager);
}
});
-
if (namespacesTracker != null) {
namespacesTracker.close();
namespacesTracker = null;
@@ -353,10 +325,6 @@ public class Activator implements BundleActivator {
debugOptionsTracker.close();
debugOptionsTracker = null;
}
- if (extensionRegistryTracker != null) {
- extensionRegistryTracker.close();
- extensionRegistryTracker = null;
- }
if (idFactoryServiceRegistration != null) {
idFactoryServiceRegistration.unregister();
idFactoryServiceRegistration = null;
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/internal/core/sharedobject/Activator.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/internal/core/sharedobject/Activator.java
index 82b77edc2..651a292c0 100644
--- a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/internal/core/sharedobject/Activator.java
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/internal/core/sharedobject/Activator.java
@@ -1,7 +1,5 @@
package org.eclipse.ecf.internal.core.sharedobject;
-import org.eclipse.core.runtime.IConfigurationElement;
-
import java.util.Map;
import java.util.Properties;
import org.eclipse.core.runtime.*;
@@ -44,11 +42,9 @@ public class Activator implements BundleActivator {
BundleContext context = null;
- ServiceTracker extensionRegistryTracker = null;
-
private ServiceTracker logServiceTracker = null;
- private ServiceTracker adapterManagerTracker = null;
+ private AdapterManagerTracker adapterManagerTracker = null;
/**
* The constructor
@@ -57,28 +53,20 @@ public class Activator implements BundleActivator {
// null constructor
}
- public IExtensionRegistry getExtensionRegistry() {
- return (IExtensionRegistry) extensionRegistryTracker.getService();
- }
-
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
- @SuppressWarnings("unchecked")
public void start(BundleContext ctxt) throws Exception {
this.context = ctxt;
plugin = this;
- // run with OptionalCodeSafeRunnable, in case extension registry isn't present
- SafeRunner.run(new OptionalCodeSafeRunnable() {
+
+ SafeRunner.run(new ExtensionRegistryRunnable(context) {
@Override
- public void run() throws Exception {
- extensionRegistryTracker = new ServiceTracker(context, IExtensionRegistry.class.getName(), null);
- extensionRegistryTracker.open();
- IExtensionRegistry reg = getExtensionRegistry();
- if (reg != null) {
- IExtensionPoint extensionPoint = reg.getExtensionPoint(SHAREDOBJECT_FACTORY_EPOINT);
+ protected void runWithRegistry(IExtensionRegistry registry) throws Exception {
+ if (registry != null) {
+ IExtensionPoint extensionPoint = registry.getExtensionPoint(SHAREDOBJECT_FACTORY_EPOINT);
if (extensionPoint != null)
addSharedObjectExtensions(extensionPoint.getConfigurationElements());
}
@@ -94,10 +82,6 @@ public class Activator implements BundleActivator {
*/
public void stop(BundleContext ctxt) throws Exception {
Trace.entering(Activator.PLUGIN_ID, SharedObjectDebugOptions.METHODS_EXITING, Activator.class, "stop"); //$NON-NLS-1$
- if (extensionRegistryTracker != null) {
- extensionRegistryTracker.close();
- extensionRegistryTracker = null;
- }
if (adapterManagerTracker != null) {
adapterManagerTracker.close();
adapterManagerTracker = null;
@@ -147,23 +131,15 @@ public class Activator implements BundleActivator {
}
}
- @SuppressWarnings("unchecked")
public IAdapterManager getAdapterManager() {
if (context == null)
return null;
// First, try to get the adapter manager via
if (adapterManagerTracker == null) {
- adapterManagerTracker = new ServiceTracker(this.context, IAdapterManager.class.getName(), null);
+ adapterManagerTracker = new AdapterManagerTracker(this.context);
adapterManagerTracker.open();
}
- IAdapterManager adapterManager = (IAdapterManager) adapterManagerTracker.getService();
- // Then, if the service isn't there, try to get from Platform class via
- // PlatformHelper class
- if (adapterManager == null)
- adapterManager = PlatformHelper.getPlatformAdapterManager();
- if (adapterManager == null)
- getDefault().log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "Cannot get adapter manager", null)); //$NON-NLS-1$
- return adapterManager;
+ return adapterManagerTracker.getAdapterManager();
}
/**
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java
index 7fa4fc59a..523051c46 100644
--- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java
+++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java
@@ -70,8 +70,6 @@ public class ECFPlugin implements BundleActivator {
BundleContext context = null;
- ServiceTracker extensionRegistryTracker = null;
-
private Map disposables = new WeakHashMap();
// This is Object rather than IExtensionRegistryManager to avoid loading
@@ -86,7 +84,7 @@ public class ECFPlugin implements BundleActivator {
private LogService logService = null;
- private ServiceTracker adapterManagerTracker = null;
+ private AdapterManagerTracker adapterManagerTracker = null;
private BundleActivator ecfTrustManager;
@@ -119,11 +117,8 @@ public class ECFPlugin implements BundleActivator {
log(new Status(IStatus.ERROR, getDefault().getBundle().getSymbolicName(), "Unexpected Error in ECFPlugin.start", t)); //$NON-NLS-1$
}
- SafeRunner.run(new OptionalCodeSafeRunnable() {
- public void run() throws Exception {
- extensionRegistryTracker = new ServiceTracker(context, IExtensionRegistry.class.getName(), null);
- extensionRegistryTracker.open();
- final IExtensionRegistry registry = getExtensionRegistry();
+ SafeRunner.run(new ExtensionRegistryRunnable(this.context) {
+ protected void runWithRegistry(IExtensionRegistry registry) throws Exception {
if (registry != null) {
registryManager = new IRegistryChangeListener() {
public void registryChanged(IRegistryChangeEvent event) {
@@ -170,10 +165,44 @@ public class ECFPlugin implements BundleActivator {
containerFactoryServiceRegistration = ctxt.registerService(IContainerFactory.class.getName(), sf, null);
containerManagerServiceRegistration = ctxt.registerService(IContainerManager.class.getName(), sf, null);
- SafeRunner.run(new OptionalCodeSafeRunnable() {
- public void run() throws Exception {
- // but eagerly start ECF startup extension
- setupStartExtensionPoint(context);
+ SafeRunner.run(new ExtensionRegistryRunnable(this.context) {
+ protected void runWithRegistry(IExtensionRegistry registry) throws Exception {
+ if (registry != null) {
+ final IExtensionPoint extensionPoint = registry.getExtensionPoint(START_EPOINT);
+ if (extensionPoint == null) {
+ return;
+ }
+ IConfigurationElement[] configurationElements = extensionPoint.getConfigurationElements();
+ final String method = "runStartExtensions"; //$NON-NLS-1$
+ // For each configuration element
+ for (int m = 0; m < configurationElements.length; m++) {
+ final IConfigurationElement member = configurationElements[m];
+ try {
+ // The only required attribute is "class"
+ boolean sync = (member.getAttribute(ASYNCH_ATTRIBUTE) == null);
+ IECFStart clazz = (IECFStart) member.createExecutableExtension(CLASS_ATTRIBUTE);
+ // Create job to do start, and schedule
+ if (sync) {
+ IStatus result = null;
+ try {
+ result = clazz.run(new NullProgressMonitor());
+ } catch (final Throwable e) {
+ final String message = "startup extension error"; //$NON-NLS-1$
+ logException(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, message, e), message, e);
+ }
+ if (result != null && !result.isOK())
+ logException(result, result.getMessage(), result.getException());
+ } else {
+ final ECFStartJob job = new ECFStartJob(clazz.getClass().getName(), clazz);
+ job.schedule();
+ }
+ } catch (final CoreException e) {
+ logException(e.getStatus(), method, e);
+ } catch (final Exception e) {
+ logException(new Status(IStatus.ERROR, getDefault().getBundle().getSymbolicName(), IStatus.ERROR, "Unknown start exception", e), method, e); //$NON-NLS-1$
+ }
+ }
+ }
}
});
}
@@ -205,11 +234,19 @@ public class ECFPlugin implements BundleActivator {
});
containerTypeDescriptionTracker.open();
}
- // Initialize from extension registry (if one exists)
- SafeRunner.run(new OptionalCodeSafeRunnable() {
- public void run() throws Exception {
- setupContainerFactoryExtensionPoint(context);
- setupContainerExtensionPoint(context);
+
+ SafeRunner.run(new ExtensionRegistryRunnable(this.context) {
+ protected void runWithRegistry(IExtensionRegistry registry) throws Exception {
+ if (registry != null) {
+ IExtensionPoint extensionPoint = registry.getExtensionPoint(CONTAINER_FACTORY_EPOINT);
+ if (extensionPoint == null)
+ return;
+ addContainerFactoryExtensions(extensionPoint.getConfigurationElements());
+ extensionPoint = registry.getExtensionPoint(CONTAINER_EPOINT);
+ if (extensionPoint == null)
+ return;
+ addContainerExtensions(extensionPoint.getConfigurationElements());
+ }
}
});
}
@@ -217,11 +254,10 @@ public class ECFPlugin implements BundleActivator {
public void stop(BundleContext ctxt) throws Exception {
fireDisposables();
this.disposables = null;
- SafeRunner.run(new OptionalCodeSafeRunnable() {
- public void run() throws Exception {
- final IExtensionRegistry reg = getExtensionRegistry();
- if (reg != null)
- reg.removeRegistryChangeListener((IRegistryChangeListener) registryManager);
+ SafeRunner.run(new ExtensionRegistryRunnable(ctxt) {
+ protected void runWithRegistry(IExtensionRegistry registry) throws Exception {
+ if (registry != null)
+ registry.removeRegistryChangeListener((IRegistryChangeListener) registryManager);
}
});
this.registryManager = null;
@@ -238,10 +274,6 @@ public class ECFPlugin implements BundleActivator {
logServiceTracker = null;
logService = null;
}
- if (extensionRegistryTracker != null) {
- extensionRegistryTracker.close();
- extensionRegistryTracker = null;
- }
if (containerFactoryServiceRegistration != null) {
containerFactoryServiceRegistration.unregister();
containerFactoryServiceRegistration = null;
@@ -486,109 +518,15 @@ public class ECFPlugin implements BundleActivator {
return results;
}
- /**
- * Setup container factory extension point
- *
- * @param bc
- * the BundleContext for this bundle
- */
- protected void setupContainerFactoryExtensionPoint(BundleContext bc) {
- final IExtensionRegistry reg = getExtensionRegistry();
- if (reg != null) {
- final IExtensionPoint extensionPoint = reg.getExtensionPoint(CONTAINER_FACTORY_EPOINT);
- if (extensionPoint == null) {
- return;
- }
- addContainerFactoryExtensions(extensionPoint.getConfigurationElements());
- }
- }
-
- protected void setupContainerExtensionPoint(BundleContext bc) {
- final IExtensionRegistry reg = getExtensionRegistry();
- if (reg != null) {
- final IExtensionPoint extensionPoint = reg.getExtensionPoint(CONTAINER_EPOINT);
- if (extensionPoint == null) {
- return;
- }
- addContainerExtensions(extensionPoint.getConfigurationElements());
- }
- }
-
- public IExtensionRegistry getExtensionRegistry() {
- if (context == null)
- return null;
- return (IExtensionRegistry) extensionRegistryTracker.getService();
- }
-
- /**
- * Setup start extension point
- *
- * @param bc
- * the BundleContext for this bundle
- */
- void setupStartExtensionPoint(BundleContext bc) {
- final IExtensionRegistry reg = getExtensionRegistry();
- if (reg != null) {
- final IExtensionPoint extensionPoint = reg.getExtensionPoint(START_EPOINT);
- if (extensionPoint == null) {
- return;
- }
- runStartExtensions(extensionPoint.getConfigurationElements());
- }
- }
-
- protected void runStartExtensions(IConfigurationElement[] configurationElements) {
- final String method = "runStartExtensions"; //$NON-NLS-1$
- // For each configuration element
- for (int m = 0; m < configurationElements.length; m++) {
- final IConfigurationElement member = configurationElements[m];
- try {
- // The only required attribute is "class"
- boolean sync = (member.getAttribute(ASYNCH_ATTRIBUTE) == null);
- IECFStart clazz = (IECFStart) member.createExecutableExtension(CLASS_ATTRIBUTE);
- startExtension(clazz.getClass().getName(), clazz, sync);
- } catch (final CoreException e) {
- logException(e.getStatus(), method, e);
- } catch (final Exception e) {
- logException(new Status(IStatus.ERROR, getDefault().getBundle().getSymbolicName(), IStatus.ERROR, "Unknown start exception", e), method, e); //$NON-NLS-1$
- }
- }
- }
-
- private void startExtension(String name, IECFStart exten, boolean synchronous) {
- // Create job to do start, and schedule
- if (synchronous) {
- IStatus result = null;
- try {
- result = exten.run(new NullProgressMonitor());
- } catch (final Throwable e) {
- final String message = "startup extension error"; //$NON-NLS-1$
- logException(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, message, e), message, e);
- }
- if (result != null && !result.isOK())
- logException(result, result.getMessage(), result.getException());
- } else {
- final ECFStartJob job = new ECFStartJob(name, exten);
- job.schedule();
- }
- }
-
public IAdapterManager getAdapterManager() {
if (context == null)
return null;
// First, try to get the adapter manager via
if (adapterManagerTracker == null) {
- adapterManagerTracker = new ServiceTracker(this.context, IAdapterManager.class.getName(), null);
+ adapterManagerTracker = new AdapterManagerTracker(this.context);
adapterManagerTracker.open();
}
- IAdapterManager adapterManager = (IAdapterManager) adapterManagerTracker.getService();
- // Then, if the service isn't there, try to get from Platform class via
- // PlatformHelper class
- if (adapterManager == null)
- adapterManager = PlatformHelper.getPlatformAdapterManager();
- if (adapterManager == null)
- getDefault().log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "Cannot get adapter manager", null)); //$NON-NLS-1$
- return adapterManager;
+ return adapterManagerTracker.getAdapterManager();
}
} \ No newline at end of file

Back to the top