diff options
author | slewis | 2014-03-27 06:35:45 +0000 |
---|---|---|
committer | slewis | 2014-03-27 06:35:45 +0000 |
commit | 75e4edba4f357e8e202787a2d2973912709b54fa (patch) | |
tree | 84849eedba85d8b93b93cb814057b3eefe00688f /examples | |
parent | aa9b4b319c5b4e3367a23f6b6f0789ddeb92738c (diff) | |
download | org.eclipse.ecf-75e4edba4f357e8e202787a2d2973912709b54fa.tar.gz org.eclipse.ecf-75e4edba4f357e8e202787a2d2973912709b54fa.tar.xz org.eclipse.ecf-75e4edba4f357e8e202787a2d2973912709b54fa.zip |
Fixes to trivial provider
Change-Id: If81e66ef7fedfbc1dff4de8906a8b9690a1fe9aa
Diffstat (limited to 'examples')
5 files changed, 24 insertions, 88 deletions
diff --git a/examples/bundles/org.eclipse.ecf.examples.provider.trivial/META-INF/MANIFEST.MF b/examples/bundles/org.eclipse.ecf.examples.provider.trivial/META-INF/MANIFEST.MF index beb52f0c5..e591a7136 100644 --- a/examples/bundles/org.eclipse.ecf.examples.provider.trivial/META-INF/MANIFEST.MF +++ b/examples/bundles/org.eclipse.ecf.examples.provider.trivial/META-INF/MANIFEST.MF @@ -5,8 +5,9 @@ Bundle-SymbolicName: org.eclipse.ecf.examples.provider.trivial;singleton:=true Bundle-Version: 1.0.200.provider Bundle-Activator: org.eclipse.ecf.internal.examples.provider.trivial.Activator Bundle-Vendor: %bundle.provider -Require-Bundle: org.eclipse.core.runtime, - org.eclipse.ecf +Require-Bundle: org.eclipse.ecf, + org.eclipse.equinox.common;bundle-version="3.6.200", + org.eclipse.equinox.registry;bundle-version="3.5.400";resolution:=optional Eclipse-LazyStart: true Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1, @@ -16,3 +17,4 @@ Export-Package: org.eclipse.ecf.examples.provider.trivial;version="1.0.0", org.eclipse.ecf.internal.examples.provider.trivial;x-internal:=true, org.eclipse.ecf.internal.examples.provider.trivial.container;x-internal:=true Bundle-Localization: bundle +Import-Package: org.osgi.framework diff --git a/examples/bundles/org.eclipse.ecf.examples.provider.trivial/plugin.xml b/examples/bundles/org.eclipse.ecf.examples.provider.trivial/plugin.xml index 7ace60c3d..4f21bafb2 100644 --- a/examples/bundles/org.eclipse.ecf.examples.provider.trivial/plugin.xml +++ b/examples/bundles/org.eclipse.ecf.examples.provider.trivial/plugin.xml @@ -19,17 +19,5 @@ server="false"> </containerFactory> </extension> - <extension - id="Trivial" - point="org.eclipse.core.runtime.applications"> - <application - cardinality="*" - thread="any" - visible="true"> - <run - class="org.eclipse.ecf.examples.provider.trivial.TrivialApplication"> - </run> - </application> - </extension> </plugin> diff --git a/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/examples/provider/trivial/TrivialApplication.java b/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/examples/provider/trivial/TrivialApplication.java deleted file mode 100644 index b34ad23d4..000000000 --- a/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/examples/provider/trivial/TrivialApplication.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.eclipse.ecf.examples.provider.trivial; - -import org.eclipse.ecf.core.IContainer; -import org.eclipse.ecf.core.IContainerFactory; -import org.eclipse.ecf.core.IContainerManager; -import org.eclipse.ecf.core.identity.ID; -import org.eclipse.ecf.core.identity.IDFactory; -import org.eclipse.ecf.core.util.ECFException; -import org.eclipse.equinox.app.IApplication; -import org.eclipse.equinox.app.IApplicationContext; -import org.osgi.util.tracker.ServiceTracker; - -public class TrivialApplication implements IApplication { - - private boolean done = false; - - private ServiceTracker containerManagerTracker; - - public Object start(IApplicationContext context) throws Exception { - try { - IContainerFactory factory = getContainerManager().getContainerFactory(); - // Create instance of trivial container - IContainer container = factory.createContainer("ecf.container.trivial"); - - // Get appropriate container adapter...e.g. IChannelContainerAdapter - // IChannelContainerAdapter containerAdapter = - // (IChannelContainerAdapter) - // container.getAdapter(IChannelContainerAdapter.class); - - // Connect - ID targetID = IDFactory.getDefault().createID( - container.getConnectNamespace(), "myid"); - container.connect(targetID, null); - - synchronized (this) { - while (!done) { - wait(); - } - } - - } catch (ECFException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return null; - } - - public void stop() { - if (containerManagerTracker != null) { - containerManagerTracker.close(); - containerManagerTracker = null; - } - synchronized (this) { - done = true; - notify(); - } - } - - protected IContainerManager getContainerManager() { - if (containerManagerTracker == null) { - containerManagerTracker = new ServiceTracker( - org.eclipse.ecf.internal.examples.provider.trivial.Activator.getDefault().getContext(), IContainerManager.class.getName(), - null); - containerManagerTracker.open(); - } - return (IContainerManager) containerManagerTracker.getService(); - } - - -} diff --git a/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/examples/provider/trivial/identity/TrivialNamespace.java b/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/examples/provider/trivial/identity/TrivialNamespace.java index 3b7ab1439..907f5436c 100644 --- a/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/examples/provider/trivial/identity/TrivialNamespace.java +++ b/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/examples/provider/trivial/identity/TrivialNamespace.java @@ -21,6 +21,10 @@ public class TrivialNamespace extends Namespace { public static final String SCHEME = "trivial"; public static final String NAME = "ecf.namespace.trivial"; + public TrivialNamespace(String name) { + super(name,null); + } + /* (non-Javadoc) * @see org.eclipse.ecf.core.identity.Namespace#createInstance(java.lang.Object[]) */ diff --git a/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/internal/examples/provider/trivial/Activator.java b/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/internal/examples/provider/trivial/Activator.java index 262938561..d17456b5b 100755 --- a/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/internal/examples/provider/trivial/Activator.java +++ b/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/internal/examples/provider/trivial/Activator.java @@ -1,12 +1,17 @@ package org.eclipse.ecf.internal.examples.provider.trivial; -import org.eclipse.core.runtime.Plugin; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.SafeRunner; +import org.eclipse.ecf.core.identity.Namespace; +import org.eclipse.ecf.core.util.ExtensionRegistryRunnable; +import org.eclipse.ecf.examples.provider.trivial.identity.TrivialNamespace; +import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; /** * The activator class controls the plug-in life cycle */ -public class Activator extends Plugin { +public class Activator implements BundleActivator { // The plug-in ID public static final String PLUGIN_ID = "org.eclipse.ecf.internal.examples.provider.trivial"; @@ -27,9 +32,17 @@ public class Activator extends Plugin { * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) */ public void start(BundleContext context) throws Exception { - super.start(context); this.context = context; plugin = this; + SafeRunner.run(new ExtensionRegistryRunnable(this.context) { + protected void runWithRegistry(IExtensionRegistry registry) + throws Exception { + // do nothing + } + protected void runWithoutRegistry() throws Exception { + Activator.this.context.registerService(Namespace.class, new TrivialNamespace("ecf.namespace.trivial"), null); + } + }); } /* @@ -38,7 +51,6 @@ public class Activator extends Plugin { */ public void stop(BundleContext context) throws Exception { plugin = null; - super.stop(context); this.context = null; } |