Merge branch 'master' into 331383
diff --git "a/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/products/Hello Service Consumer \050zeroconf,r-osgi\051.product" "b/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/products/Hello Service Consumer \050zeroconf,r-osgi\051.product"
index 87026b8..441d4c7 100644
--- "a/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/products/Hello Service Consumer \050zeroconf,r-osgi\051.product"
+++ "b/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/products/Hello Service Consumer \050zeroconf,r-osgi\051.product"
@@ -1,56 +1,61 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?pde version="3.5"?>
-
-<product name="R-OSGi Hello Consumer Zeroconf Discovery" uid="org.eclipse.ecf.examples.remoteservices.hello.consumer.zeroconf.rosgi" application="org.eclipse.ecf.examples.remoteservices.hello.consumer.HelloConsumer" version="1.0.0" useFeatures="false" includeLaunchers="false">
-
- <configIni use="default">
- </configIni>
-
- <launcherArgs>
- <programArgs>-console -consoleLog</programArgs>
- <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
- </launcherArgs>
-
- <launcher>
- <solaris/>
- <win useIco="false">
- <bmp/>
- </win>
- </launcher>
-
- <vm>
- </vm>
-
- <plugins>
- <plugin id="ch.ethz.iks.r_osgi.remote"/>
- <plugin id="ch.ethz.iks.slp"/>
- <plugin id="org.eclipse.core.contenttype"/>
- <plugin id="org.eclipse.core.jobs"/>
- <plugin id="org.eclipse.core.runtime"/>
- <plugin id="org.eclipse.ecf"/>
- <plugin id="org.eclipse.ecf.discovery"/>
- <plugin id="org.eclipse.ecf.examples.remoteservices.hello"/>
- <plugin id="org.eclipse.ecf.examples.remoteservices.hello.consumer"/>
- <plugin id="org.eclipse.ecf.identity"/>
- <plugin id="org.eclipse.ecf.osgi.services.distribution"/>
- <plugin id="org.eclipse.ecf.osgi.services.remoteserviceadmin"/>
- <plugin id="org.eclipse.ecf.osgi.services.remoteserviceadmin.proxy"/>
- <plugin id="org.eclipse.ecf.provider"/>
- <plugin id="org.eclipse.ecf.provider.jmdns"/>
- <plugin id="org.eclipse.ecf.provider.jslp"/>
- <plugin id="org.eclipse.ecf.provider.r_osgi"/>
- <plugin id="org.eclipse.ecf.remoteservice"/>
- <plugin id="org.eclipse.ecf.sharedobject"/>
- <plugin id="org.eclipse.equinox.app"/>
- <plugin id="org.eclipse.equinox.common"/>
- <plugin id="org.eclipse.equinox.concurrent"/>
- <plugin id="org.eclipse.equinox.preferences"/>
- <plugin id="org.eclipse.equinox.registry"/>
- <plugin id="org.eclipse.osgi"/>
- <plugin id="org.eclipse.osgi.services"/>
- <plugin id="org.eclipse.osgi.services.remoteserviceadmin"/>
- <plugin id="org.objectweb.asm"/>
- </plugins>
-
-
-</product>
+<?xml version="1.0" encoding="UTF-8"?>
+<?pde version="3.5"?>
+
+<product name="R-OSGi Hello Consumer Zeroconf Discovery" uid="org.eclipse.ecf.examples.remoteservices.hello.consumer.zeroconf.rosgi" application="org.eclipse.ecf.examples.remoteservices.hello.consumer.HelloConsumer" version="1.0.0" useFeatures="false" includeLaunchers="false">
+
+
+ <configIni use="default">
+ </configIni>
+
+ <launcherArgs>
+ <programArgs>-console -consoleLog</programArgs>
+ <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
+ </launcherArgs>
+
+ <windowImages/>
+
+
+ <launcher>
+ <solaris/>
+ <win useIco="false">
+ <bmp/>
+ </win>
+ </launcher>
+
+
+ <vm>
+ </vm>
+
+
+ <plugins>
+ <plugin id="ch.ethz.iks.r_osgi.remote"/>
+ <plugin id="ch.ethz.iks.slp"/>
+ <plugin id="org.eclipse.core.contenttype"/>
+ <plugin id="org.eclipse.core.jobs"/>
+ <plugin id="org.eclipse.core.runtime"/>
+ <plugin id="org.eclipse.ecf"/>
+ <plugin id="org.eclipse.ecf.discovery"/>
+ <plugin id="org.eclipse.ecf.examples.remoteservices.hello"/>
+ <plugin id="org.eclipse.ecf.examples.remoteservices.hello.consumer"/>
+ <plugin id="org.eclipse.ecf.identity"/>
+ <plugin id="org.eclipse.ecf.osgi.services.distribution"/>
+ <plugin id="org.eclipse.ecf.osgi.services.remoteserviceadmin"/>
+ <plugin id="org.eclipse.ecf.osgi.services.remoteserviceadmin.proxy"/>
+ <plugin id="org.eclipse.ecf.provider"/>
+ <plugin id="org.eclipse.ecf.provider.jmdns"/>
+ <plugin id="org.eclipse.ecf.provider.r_osgi"/>
+ <plugin id="org.eclipse.ecf.remoteservice"/>
+ <plugin id="org.eclipse.ecf.sharedobject"/>
+ <plugin id="org.eclipse.equinox.app"/>
+ <plugin id="org.eclipse.equinox.common"/>
+ <plugin id="org.eclipse.equinox.concurrent"/>
+ <plugin id="org.eclipse.equinox.preferences"/>
+ <plugin id="org.eclipse.equinox.registry"/>
+ <plugin id="org.eclipse.osgi"/>
+ <plugin id="org.eclipse.osgi.services"/>
+ <plugin id="org.eclipse.osgi.services.remoteserviceadmin"/>
+ <plugin id="org.objectweb.asm"/>
+ </plugins>
+
+
+</product>
diff --git a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/util/SimpleFIFOQueue.java b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/util/SimpleFIFOQueue.java
index 1942fc4..7abc8de 100644
--- a/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/util/SimpleFIFOQueue.java
+++ b/framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/util/SimpleFIFOQueue.java
@@ -17,7 +17,7 @@
public class SimpleFIFOQueue implements ISimpleFIFOQueue {
private final List list;
- private boolean stopped;
+ private volatile boolean stopped;
public SimpleFIFOQueue() {
list = new LinkedList();
diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractConsumerContainerSelector.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractConsumerContainerSelector.java
index 3eb2bce..19f8b6f 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractConsumerContainerSelector.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractConsumerContainerSelector.java
@@ -188,6 +188,9 @@
return null;
}
+ /**
+ * @since 2.0
+ */
protected IRemoteServiceContainer createContainer(
ContainerTypeDescription containerTypeDescription,
String containerTypeDescriptionName, Map properties)
diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractContainerSelector.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractContainerSelector.java
index a395f39..0838116 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractContainerSelector.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractContainerSelector.java
@@ -156,6 +156,9 @@
}
}
+ /**
+ * @since 2.0
+ */
protected Object getContainerFactoryArguments(
ServiceReference serviceReference, Map<String, Object> properties,
ContainerTypeDescription containerTypeDescription) {
diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/SelectContainerException.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/SelectContainerException.java
index 6c175ce..39fbe80 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/SelectContainerException.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/SelectContainerException.java
@@ -11,6 +11,9 @@
import org.eclipse.ecf.core.ContainerTypeDescription;
+/**
+ * @since 2.0
+ */
public class SelectContainerException extends Exception {
private static final long serialVersionUID = -5507248105370677422L;
diff --git a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/JMDNSPlugin.java b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/JMDNSPlugin.java
index 6caaefb..620ccbd 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/JMDNSPlugin.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/JMDNSPlugin.java
@@ -77,36 +77,46 @@
props.put(IDiscoveryService.CONTAINER_NAME, NAME);
props.put(Constants.SERVICE_RANKING, new Integer(750));
String[] clazzes = new String[] {IDiscoveryService.class.getName(), IDiscoveryLocator.class.getName(), IDiscoveryAdvertiser.class.getName()};
- serviceRegistration = context.registerService(clazzes, new ServiceFactory() {
- private volatile JMDNSDiscoveryContainer jdc;
+ serviceRegistration = context.registerService(clazzes, serviceFactory, props);
+ }
- /* (non-Javadoc)
- * @see org.osgi.framework.ServiceFactory#getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration)
- */
- public Object getService(final Bundle bundle, final ServiceRegistration registration) {
- if (jdc == null) {
- try {
- jdc = new JMDNSDiscoveryContainer();
- jdc.connect(null, null);
- } catch (final IDCreateException e) {
- Trace.catching(JMDNSPlugin.PLUGIN_ID, JMDNSDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "getService(Bundle, ServiceRegistration)", e); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (final ContainerConnectException e) {
- Trace.catching(JMDNSPlugin.PLUGIN_ID, JMDNSDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "getService(Bundle, ServiceRegistration)", e); //$NON-NLS-1$ //$NON-NLS-2$
- jdc = null;
- }
+ private final DiscoveryServiceFactory serviceFactory = new DiscoveryServiceFactory();
+
+ class DiscoveryServiceFactory implements ServiceFactory {
+ private volatile JMDNSDiscoveryContainer jdc;
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.ServiceFactory#getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration)
+ */
+ public Object getService(final Bundle bundle, final ServiceRegistration registration) {
+ if (jdc == null) {
+ try {
+ jdc = new JMDNSDiscoveryContainer();
+ jdc.connect(null, null);
+ } catch (final IDCreateException e) {
+ Trace.catching(JMDNSPlugin.PLUGIN_ID, JMDNSDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "getService(Bundle, ServiceRegistration)", e); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (final ContainerConnectException e) {
+ Trace.catching(JMDNSPlugin.PLUGIN_ID, JMDNSDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "getService(Bundle, ServiceRegistration)", e); //$NON-NLS-1$ //$NON-NLS-2$
+ jdc = null;
}
- return jdc;
}
+ return jdc;
+ }
- /* (non-Javadoc)
- * @see org.osgi.framework.ServiceFactory#ungetService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration, java.lang.Object)
- */
- public void ungetService(final Bundle bundle, final ServiceRegistration registration, final Object service) {
- //TODO-mkuppe we later might want to dispose jSLP when the last!!! consumer ungets the service
- //Though don't forget about the (ECF) Container which might still be in use
- }
- }, props);
+ /**
+ * @return false if this factory has never created a service instance, true otherwise
+ */
+ public boolean isActive() {
+ return jdc != null;
+ }
+ /* (non-Javadoc)
+ * @see org.osgi.framework.ServiceFactory#ungetService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration, java.lang.Object)
+ */
+ public void ungetService(final Bundle bundle, final ServiceRegistration registration, final Object service) {
+ //TODO-mkuppe we later might want to dispose jmDNS when the last!!! consumer ungets the service
+ //Though don't forget about the (ECF) Container which might still be in use
+ }
}
protected Bundle getBundle() {
@@ -120,7 +130,7 @@
* This method is called when the plug-in is stopped
*/
public void stop(final BundleContext ctxt) throws Exception {
- if (serviceRegistration != null) {
+ if (serviceRegistration != null && serviceFactory.isActive()) {
ServiceReference reference = serviceRegistration.getReference();
IDiscoveryLocator aLocator = (IDiscoveryLocator) ctxt.getService(reference);
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 b21ee7a..3a09c54 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
@@ -94,33 +94,44 @@
props.put(Constants.SERVICE_RANKING, new Integer(500));
String[] clazzes = new String[] {IDiscoveryService.class.getName(), IDiscoveryLocator.class.getName(), IDiscoveryAdvertiser.class.getName()};
- serviceRegistration = context.registerService(clazzes, new ServiceFactory() {
- private volatile JSLPDiscoveryContainer jdc;
+ serviceRegistration = context.registerService(clazzes, serviceFactory, props);
+ }
- /* (non-Javadoc)
- * @see org.osgi.framework.ServiceFactory#getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration)
- */
- public Object getService(final Bundle bundle, final ServiceRegistration registration) {
- if (jdc == null) {
- try {
- jdc = new JSLPDiscoveryContainer();
- jdc.connect(null, null);
- } catch (final 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;
- }
+ private final DiscoveryServiceFactory serviceFactory = new DiscoveryServiceFactory();
+
+ class DiscoveryServiceFactory implements ServiceFactory {
+ private volatile JSLPDiscoveryContainer jdc;
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.ServiceFactory#getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration)
+ */
+ public Object getService(final Bundle bundle, final ServiceRegistration registration) {
+ if (jdc == null) {
+ try {
+ jdc = new JSLPDiscoveryContainer();
+ jdc.connect(null, null);
+ } catch (final 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;
}
+ return jdc;
+ }
- /* (non-Javadoc)
- * @see org.osgi.framework.ServiceFactory#ungetService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration, java.lang.Object)
- */
- public void ungetService(final Bundle bundle, final ServiceRegistration registration, final Object service) {
- //TODO-mkuppe we later might want to dispose jSLP when the last!!! consumer ungets the service
- //Though don't forget about the (ECF) Container which might still be in use
- }
- }, props);
+ /**
+ * @return false if this factory has never created a service instance, true otherwise
+ */
+ public boolean isActive() {
+ return jdc != null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.ServiceFactory#ungetService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration, java.lang.Object)
+ */
+ public void ungetService(final Bundle bundle, final ServiceRegistration registration, final Object service) {
+ //TODO-mkuppe we later might want to dispose jSLP when the last!!! consumer ungets the service
+ //Though don't forget about the (ECF) Container which might still be in use
+ }
}
/*
@@ -130,7 +141,7 @@
*/
public void stop(final BundleContext context) throws Exception {
//TODO-mkuppe here we should do something like a deregisterAll(), but see ungetService(...);
- if (serviceRegistration != null) {
+ if (serviceRegistration != null && serviceFactory.isActive()) {
ServiceReference reference = serviceRegistration.getReference();
IDiscoveryLocator aLocator = (IDiscoveryLocator) context.getService(reference);