Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis@composent.com2010-10-24 15:57:16 -0400
committerslewis@composent.com2010-10-24 15:57:16 -0400
commit2fc54d10444076dc7628a3bb43551a1b2b5b8ac4 (patch)
tree4f43d72f3887fd3edc5fb822785df6d507e7e480
parentbd373cefab63c5644d3ce153221262f2ed7eb50a (diff)
downloadorg.eclipse.ecf-2fc54d10444076dc7628a3bb43551a1b2b5b8ac4.tar.gz
org.eclipse.ecf-2fc54d10444076dc7628a3bb43551a1b2b5b8ac4.tar.xz
org.eclipse.ecf-2fc54d10444076dc7628a3bb43551a1b2b5b8ac4.zip
Additions for rsa
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java36
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LocatorServiceListener.java11
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionFactory.java7
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractServiceInfoFactory.java10
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IEndpointDescriptionFactory.java7
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IServiceInfoFactory.java4
-rw-r--r--incubation/bundles/org.eclipse.ecf.provider.endpointdescription.localdiscovery/src/org/eclipse/ecf/provider/internal/endpointdescription/localdiscovery/Activator.java3
7 files changed, 51 insertions, 27 deletions
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java
index 9c66f2572..2c770f9e0 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java
@@ -58,8 +58,6 @@ public class Activator implements BundleActivator {
private ServiceRegistration endpointDescriptionFactoryRegistration;
private IExecutor executor;
-
- private LocatorServiceListener locatorServiceListener;
private ServiceTracker locatorServiceTracker;
private ServiceTracker endpointListenerServiceTracker;
@@ -69,7 +67,8 @@ public class Activator implements BundleActivator {
private LogService logService = null;
private Object logServiceTrackerLock = new Object();
-
+ private Map<IDiscoveryLocator, LocatorServiceListener> locatorListeners;
+
/*
* (non-Javadoc)
*
@@ -94,8 +93,7 @@ public class Activator implements BundleActivator {
executor = new ThreadsExecutor();
- // Create service listener
- locatorServiceListener = new LocatorServiceListener();
+ locatorListeners = new HashMap();
// Create locator service tracker
locatorServiceTracker = new ServiceTracker(context,
IDiscoveryLocator.class.getName(),
@@ -117,17 +115,23 @@ public class Activator implements BundleActivator {
void openLocator(IDiscoveryLocator locator) {
if (locator == null || context == null)
return;
- locator.addServiceListener(locatorServiceListener);
- processInitialLocatorServices(locator);
+ synchronized (locatorListeners) {
+ LocatorServiceListener locatorListener = new LocatorServiceListener(locator);
+ locatorListeners.put(locator, locatorListener);
+ processInitialLocatorServices(locator,locatorListener);
+ }
}
void shutdownLocator(IDiscoveryLocator locator) {
if (locator == null || context == null)
return;
- locator.removeServiceListener(locatorServiceListener);
+ synchronized (locatorListeners) {
+ LocatorServiceListener locatorListener = locatorListeners.remove(locator);
+ if (locatorListener != null) locatorListener.close();
+ }
}
- private void processInitialLocatorServices(final IDiscoveryLocator locator) {
+ private void processInitialLocatorServices(final IDiscoveryLocator locator, final LocatorServiceListener locatorListener) {
IProgressRunnable runnable = new IProgressRunnable() {
public Object run(IProgressMonitor arg0) throws Exception {
if (context == null)
@@ -136,7 +140,7 @@ public class Activator implements BundleActivator {
if (context == null)
return null;
for (int i = 0; i < serviceInfos.length; i++) {
- locatorServiceListener.handleService(serviceInfos[i], true);
+ locatorListener.handleService(serviceInfos[i], true);
}
return null;
}
@@ -202,12 +206,22 @@ public class Activator implements BundleActivator {
locatorServiceTracker.close();
locatorServiceTracker = null;
}
- locatorServiceListener.close();
+ shutdownLocatorListeners();
executor = null;
Activator.context = null;
Activator.instance = null;
}
+ private void shutdownLocatorListeners() {
+ synchronized (locatorListeners) {
+ for(IDiscoveryLocator l: locatorListeners.keySet()) {
+ LocatorServiceListener locatorListener = locatorListeners.get(l);
+ if (locatorListener != null) locatorListener.close();
+ }
+ locatorListeners.clear();
+ }
+ }
+
protected LogService getLogService() {
if (context == null)
return null;
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LocatorServiceListener.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LocatorServiceListener.java
index 7da6a491e..9d2bc8ed3 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LocatorServiceListener.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LocatorServiceListener.java
@@ -15,6 +15,7 @@ import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
+import org.eclipse.ecf.discovery.IDiscoveryLocator;
import org.eclipse.ecf.discovery.IServiceEvent;
import org.eclipse.ecf.discovery.IServiceInfo;
import org.eclipse.ecf.discovery.IServiceListener;
@@ -39,6 +40,8 @@ class LocatorServiceListener implements IServiceListener {
private ListenerQueue queue;
private EventManager eventManager;
+ private IDiscoveryLocator locator;
+
class EndpointListenerEvent {
private EndpointListenerHolder holder;
@@ -59,7 +62,8 @@ class LocatorServiceListener implements IServiceListener {
}
}
- public LocatorServiceListener() {
+ public LocatorServiceListener(IDiscoveryLocator locator) {
+ this.locator = locator;
}
public void serviceDiscovered(IServiceEvent anEvent) {
@@ -201,8 +205,8 @@ class LocatorServiceListener implements IServiceListener {
// EndpointDescription
// for given serviceID and serviceInfo
return (discovered) ? factory
- .createDiscoveredEndpointDescription(serviceInfo) : factory
- .getUndiscoveredEndpointDescription(serviceId);
+ .createDiscoveredEndpointDescription(locator, serviceInfo) : factory
+ .getUndiscoveredEndpointDescription(locator, serviceId);
} catch (Exception e) {
logError("Exception calling IEndpointDescriptionFactory."
+ ((discovered) ? "createDiscoveredEndpointDescription"
@@ -229,5 +233,6 @@ class LocatorServiceListener implements IServiceListener {
}
}
}
+ locator = null;
}
} \ No newline at end of file
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionFactory.java
index 8fbdc22e7..6d7cc9afd 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionFactory.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionFactory.java
@@ -1,17 +1,20 @@
package org.eclipse.ecf.osgi.services.remoteserviceadmin;
+import org.eclipse.ecf.discovery.IDiscoveryLocator;
import org.eclipse.ecf.discovery.IServiceInfo;
import org.eclipse.ecf.discovery.identity.IServiceID;
public abstract class AbstractEndpointDescriptionFactory extends AbstractMetadataFactory implements IEndpointDescriptionFactory {
- public EndpointDescription createDiscoveredEndpointDescription(
+ public EndpointDescription createDiscoveredEndpointDescription(IDiscoveryLocator locator,
IServiceInfo discoveredServiceInfo) {
+ // XXX todo
return null;
}
- public EndpointDescription getUndiscoveredEndpointDescription(
+ public EndpointDescription getUndiscoveredEndpointDescription(IDiscoveryLocator locator,
IServiceID serviceID) {
+ // XXX todo
return null;
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractServiceInfoFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractServiceInfoFactory.java
index 1efb90480..95e468ddf 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractServiceInfoFactory.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractServiceInfoFactory.java
@@ -50,9 +50,8 @@ public abstract class AbstractServiceInfoFactory extends
}
}
- public IServiceInfo createServiceInfoForDiscovery(
- EndpointDescription endpointDescription,
- IDiscoveryAdvertiser advertiser) {
+ public IServiceInfo createServiceInfoForDiscovery(IDiscoveryAdvertiser advertiser,
+ EndpointDescription endpointDescription) {
Namespace advertiserNamespace = advertiser.getServicesNamespace();
ServiceInfoKey key = new ServiceInfoKey(endpointDescription,
advertiserNamespace);
@@ -183,9 +182,8 @@ public abstract class AbstractServiceInfoFactory extends
protocols, namingAuthority);
}
- public IServiceInfo removeServiceInfoForUndiscovery(
- EndpointDescription endpointDescription,
- IDiscoveryAdvertiser advertiser) {
+ public IServiceInfo removeServiceInfoForUndiscovery(IDiscoveryAdvertiser advertiser,
+ EndpointDescription endpointDescription) {
Namespace advertiserNamespace = advertiser.getServicesNamespace();
ServiceInfoKey key = new ServiceInfoKey(endpointDescription,
advertiserNamespace);
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IEndpointDescriptionFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IEndpointDescriptionFactory.java
index a0d737f0e..ac9ebcd87 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IEndpointDescriptionFactory.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IEndpointDescriptionFactory.java
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.ecf.osgi.services.remoteserviceadmin;
+import org.eclipse.ecf.discovery.IDiscoveryLocator;
import org.eclipse.ecf.discovery.IServiceInfo;
import org.eclipse.ecf.discovery.identity.IServiceID;
@@ -20,23 +21,25 @@ public interface IEndpointDescriptionFactory {
* associated distribution system (e.g. ECFEndpointDescription). Implementers should return
* <code>null</code> if no notification should occur.
*
+ * @param locator the locator responsible for the discoveredServiceInfo. Must not be <code>null</code>.
* @param discoveredServiceInfo the discovered service info. Must not be <code>null</code>.
* @return EndpointDescription that will be used to notify EndpointListeners
* about a new EndpointDescription. If <code>null</code> is returned, no
* notification should be performed by the calling code.
*/
- public EndpointDescription createDiscoveredEndpointDescription(IServiceInfo discoveredServiceInfo);
+ public EndpointDescription createDiscoveredEndpointDescription(IDiscoveryLocator locator, IServiceInfo discoveredServiceInfo);
/**
* Get an EndpointDescription for an undiscovered remote service. Implementers of this
* factory service may return the type of EndpointDescription appropriate for the
* associated distribution system (e.g. ECFEndpointDescription). Implementers should return
* <code>null</code> if no notification should occur.
*
+ * @param locator the locator responsible for the discoveredServiceInfo. Must not be <code>null</code>.
* @param serviceId the discovered service ID. Must not be <code>null</code>.
* @return EndpointDescription that will be used to notify EndpointListeners
* about an undiscovered EndpointDescription. If <code>null</code> is returned, no
* notification should be performed by the calling code.
*/
- public EndpointDescription getUndiscoveredEndpointDescription(IServiceID serviceID);
+ public EndpointDescription getUndiscoveredEndpointDescription(IDiscoveryLocator locator, IServiceID serviceID);
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IServiceInfoFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IServiceInfoFactory.java
index 6e7d0648e..ecc7a2820 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IServiceInfoFactory.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IServiceInfoFactory.java
@@ -5,8 +5,8 @@ import org.eclipse.ecf.discovery.IServiceInfo;
public interface IServiceInfoFactory {
- public IServiceInfo createServiceInfoForDiscovery(EndpointDescription endpointDescription, IDiscoveryAdvertiser advertiser);
+ public IServiceInfo createServiceInfoForDiscovery(IDiscoveryAdvertiser advertiser, EndpointDescription endpointDescription);
- public IServiceInfo removeServiceInfoForUndiscovery(EndpointDescription endpointDescription, IDiscoveryAdvertiser advertiser);
+ public IServiceInfo removeServiceInfoForUndiscovery(IDiscoveryAdvertiser advertiser, EndpointDescription endpointDescription);
}
diff --git a/incubation/bundles/org.eclipse.ecf.provider.endpointdescription.localdiscovery/src/org/eclipse/ecf/provider/internal/endpointdescription/localdiscovery/Activator.java b/incubation/bundles/org.eclipse.ecf.provider.endpointdescription.localdiscovery/src/org/eclipse/ecf/provider/internal/endpointdescription/localdiscovery/Activator.java
index d94d4c851..12ba47a7a 100644
--- a/incubation/bundles/org.eclipse.ecf.provider.endpointdescription.localdiscovery/src/org/eclipse/ecf/provider/internal/endpointdescription/localdiscovery/Activator.java
+++ b/incubation/bundles/org.eclipse.ecf.provider.endpointdescription.localdiscovery/src/org/eclipse/ecf/provider/internal/endpointdescription/localdiscovery/Activator.java
@@ -72,6 +72,7 @@ public class Activator implements BundleActivator {
return result;
}
+
private void testParseServiceDescription() {
try {
URL file = context.getBundle().getEntry("/endpointdescription1.xml");
@@ -84,7 +85,7 @@ public class Activator implements BundleActivator {
Map props = convertProperties(d.getProperties());
EndpointDescription ed = new EndpointDescription(props);
System.out.println("endpoint description="+ed);
- IServiceInfo serviceInfo = serviceInfoFactory.createServiceInfoForDiscovery(ed,null);
+ IServiceInfo serviceInfo = serviceInfoFactory.createServiceInfoForDiscovery(null, ed);
System.out.println("serviceInfo="+serviceInfo);
}
} catch (Exception e) {

Back to the top