Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Alexander Kuppe2011-11-30 14:41:09 -0500
committerMarkus Alexander Kuppe2011-11-30 14:41:09 -0500
commitaa076a089db5c7a867dbfab63a21ad0b5628461c (patch)
tree373ae1476d9e3c2a390ad7014454c73a568adb5a
parented1a83afe2be821a619ef82c2d51f73fc8f26e21 (diff)
parentb0f6a4ed8fa0e8ceccfbad93ae0a5ec69521c00e (diff)
downloadorg.eclipse.ecf-331383.tar.gz
org.eclipse.ecf-331383.tar.xz
org.eclipse.ecf-331383.zip
Merge branch 'master' into 331383331383
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/products/Hello Service Consumer (zeroconf,r-osgi).product117
-rw-r--r--framework/bundles/org.eclipse.ecf.sharedobject/src/org/eclipse/ecf/core/sharedobject/util/SimpleFIFOQueue.java2
-rw-r--r--osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractConsumerContainerSelector.java3
-rw-r--r--osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractContainerSelector.java3
-rw-r--r--osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/SelectContainerException.java3
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/JMDNSPlugin.java64
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/Activator.java61
7 files changed, 144 insertions, 109 deletions
diff --git a/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/products/Hello Service Consumer (zeroconf,r-osgi).product b/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/products/Hello Service Consumer (zeroconf,r-osgi).product
index 87026b8dc..441d4c7b7 100644
--- a/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/products/Hello Service Consumer (zeroconf,r-osgi).product
+++ b/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/products/Hello Service Consumer (zeroconf,r-osgi).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 1942fc4b9..7abc8de6b 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 @@ import java.util.List;
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 3eb2bcefc..19f8b6f85 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 @@ public class AbstractConsumerContainerSelector extends
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 a395f3930..08381168c 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 @@ public abstract class AbstractContainerSelector {
}
}
+ /**
+ * @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 6c175ce83..39fbe8003 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 @@ package org.eclipse.ecf.osgi.services.remoteserviceadmin;
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 6caaefb99..620ccbd69 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 @@ public class JMDNSPlugin implements BundleActivator {
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;
-
- /* (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;
- }
+ serviceRegistration = context.registerService(clazzes, serviceFactory, props);
+ }
+
+ 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 @@ public class JMDNSPlugin implements BundleActivator {
* 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 b21ee7a28..3a09c540b 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 @@ public class Activator implements BundleActivator {
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;
-
- /* (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;
- }
+ serviceRegistration = context.registerService(clazzes, serviceFactory, props);
+ }
+
+ 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 class Activator implements BundleActivator {
*/
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);

Back to the top