Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2008-11-08 20:29:03 -0500
committermkuppe2008-11-08 20:29:03 -0500
commit5a44cfceb1a8aaa7f627d540a099d1a4e68c28f9 (patch)
tree7fb4cd3b02efd55d372e9a447755c8bdc91e7bf3
parent202a3dd5bd985ada11e3e9ce6fb16c662ceabff6 (diff)
downloadorg.eclipse.ecf-5a44cfceb1a8aaa7f627d540a099d1a4e68c28f9.tar.gz
org.eclipse.ecf-5a44cfceb1a8aaa7f627d540a099d1a4e68c28f9.tar.xz
org.eclipse.ecf-5a44cfceb1a8aaa7f627d540a099d1a4e68c28f9.zip
NEW - bug 254687: [Discovery][SLP] ClassCircularityError during bundle activation
https://bugs.eclipse.org/bugs/show_bug.cgi?id=254687
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/Activator.java43
1 files changed, 36 insertions, 7 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/Activator.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/Activator.java
index d68b5beca..7f88f6e64 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/Activator.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/Activator.java
@@ -14,6 +14,10 @@ import ch.ethz.iks.slp.Advertiser;
import ch.ethz.iks.slp.Locator;
import java.util.Properties;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.ecf.core.ContainerConnectException;
+import org.eclipse.ecf.core.identity.IDCreateException;
+import org.eclipse.ecf.core.identity.IDFactory;
+import org.eclipse.ecf.core.util.Trace;
import org.eclipse.ecf.discovery.service.IDiscoveryService;
import org.eclipse.ecf.provider.jslp.container.JSLPDiscoveryContainer;
import org.osgi.framework.*;
@@ -65,7 +69,7 @@ public class Activator implements BundleActivator {
*
* @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
- public void start(BundleContext context) throws Exception {
+ public void start(final BundleContext context) throws Exception {
bundleContext = context;
// initially get the locator and add a life cycle listener
@@ -105,13 +109,38 @@ public class Activator implements BundleActivator {
}
}, "(" + Constants.OBJECTCLASS + "=" + Advertiser.class.getName() + ")"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- // register the jSLP discovery service (will be automatically unregistered when this bundle gets uninstalled)
- JSLPDiscoveryContainer ids = new JSLPDiscoveryContainer();
- ids.connect(null, null);
Properties props = new Properties();
- props.put(IDiscoveryService.CONTAINER_ID, ids.getID());
+ props.put(IDiscoveryService.CONTAINER_ID, IDFactory.getDefault().createStringID("org.eclipse.ecf.provider.jslp.container.JSLPDiscoveryContainer")); //$NON-NLS-1$
props.put(IDiscoveryService.CONTAINER_NAME, JSLPDiscoveryContainer.NAME);
- context.registerService(IDiscoveryService.class.getName(), ids, props);
+
+ context.registerService(IDiscoveryService.class.getName(), new ServiceFactory() {
+ private volatile JSLPDiscoveryContainer jdc;
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.ServiceFactory#getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration)
+ */
+ public Object getService(Bundle bundle, ServiceRegistration registration) {
+ if (jdc == null) {
+ try {
+ jdc = new JSLPDiscoveryContainer();
+ jdc.connect(null, null);
+ } catch (IDCreateException e) {
+ Trace.catching(Activator.PLUGIN_ID, Activator.PLUGIN_ID + "/debug/methods/tracing", this.getClass(), "getService(Bundle, ServiceRegistration)", e); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (ContainerConnectException e) {
+ Trace.catching(Activator.PLUGIN_ID, Activator.PLUGIN_ID + "/debug/methods/tracing", this.getClass(), "getService(Bundle, ServiceRegistration)", e); //$NON-NLS-1$ //$NON-NLS-2$
+ jdc = null;
+ }
+ }
+ return jdc;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.ServiceFactory#ungetService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration, java.lang.Object)
+ */
+ public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
+ //TODO-mkuppe we later might want to dispose jSLP when the last!!! consumer ungets the service
+ }
+ }, props);
}
/*
@@ -120,7 +149,7 @@ public class Activator implements BundleActivator {
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
- //TODO-mkuppe here we should do something like a deregisterAll();
+ //TODO-mkuppe here we should do something like a deregisterAll(), but see ungetService(...);
plugin = null;
bundleContext = null;
}

Back to the top