diff options
author | mkuppe | 2010-07-08 08:23:41 +0000 |
---|---|---|
committer | mkuppe | 2010-07-08 08:23:41 +0000 |
commit | 677e92e69b53d35dfa9c81bda0748a0f5c2bbaa1 (patch) | |
tree | 34d1fb790d7091438031320d87f1aad296a41257 | |
parent | 180858c4c13dba02aaf82b7c5510fe16a87b85fc (diff) | |
download | org.eclipse.ecf-677e92e69b53d35dfa9c81bda0748a0f5c2bbaa1.tar.gz org.eclipse.ecf-677e92e69b53d35dfa9c81bda0748a0f5c2bbaa1.tar.xz org.eclipse.ecf-677e92e69b53d35dfa9c81bda0748a0f5c2bbaa1.zip |
REOPENED - bug 254684: [core] defer extension registry processing
https://bugs.eclipse.org/bugs/show_bug.cgi?id=254684
-rw-r--r-- | framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ContainerFactory.java | 8 | ||||
-rw-r--r-- | framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java | 26 |
2 files changed, 28 insertions, 6 deletions
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ContainerFactory.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ContainerFactory.java index 28ed6f6d9..a7b7dc639 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ContainerFactory.java +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ContainerFactory.java @@ -49,6 +49,8 @@ public class ContainerFactory implements IContainerFactory, IContainerManager { private static IContainerFactory instance = null; + private volatile static boolean init = false; + static { instance = new ContainerFactory(); } @@ -71,7 +73,11 @@ public class ContainerFactory implements IContainerFactory, IContainerManager { } } - public static IContainerFactory getDefault() { + public synchronized static IContainerFactory getDefault() { + if (init == false) { + ECFPlugin.getDefault().initializeExtensions(); + init = true; + } return instance; } 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 3f7422bf4..e7b5ccaaa 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 @@ -124,11 +124,27 @@ public class ECFPlugin implements BundleActivator { this.registryManager = new ECFRegistryManager(); registry.addRegistryChangeListener(registryManager); } - containerFactoryServiceRegistration = ctxt.registerService(IContainerFactory.class.getName(), ContainerFactory.getDefault(), null); - containerManagerServiceRegistration = ctxt.registerService(IContainerManager.class.getName(), ContainerFactory.getDefault(), null); - setupContainerFactoryExtensionPoint(ctxt); - setupContainerExtensionPoint(ctxt); - setupStartExtensionPoint(ctxt); + + // defer extension execution until first consumer calls + final ServiceFactory sf = new ServiceFactory() { + public Object getService(Bundle bundle, ServiceRegistration registration) { + return ContainerFactory.getDefault(); + } + + public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) { + // NOP + } + }; + containerFactoryServiceRegistration = ctxt.registerService(IContainerFactory.class.getName(), sf, null); + containerManagerServiceRegistration = ctxt.registerService(IContainerManager.class.getName(), sf, null); + + // but eagerly start ECF startup extension + setupStartExtensionPoint(context); + } + + public void initializeExtensions() { + setupContainerFactoryExtensionPoint(context); + setupContainerExtensionPoint(context); } public void stop(BundleContext ctxt) throws Exception { |