diff options
author | mkuppe | 2009-03-14 12:14:11 +0000 |
---|---|---|
committer | mkuppe | 2009-03-14 12:14:11 +0000 |
commit | 57d0cc182550bd097c5ac82c9e562726d7d6ab23 (patch) | |
tree | 1a92946e0b49052578b30970ae6af978ab96c724 /compendium/bundles | |
parent | ce9fa15ab699a47105a1611e658f64c4b3515775 (diff) | |
download | org.eclipse.ecf-57d0cc182550bd097c5ac82c9e562726d7d6ab23.tar.gz org.eclipse.ecf-57d0cc182550bd097c5ac82c9e562726d7d6ab23.tar.xz org.eclipse.ecf-57d0cc182550bd097c5ac82c9e562726d7d6ab23.zip |
NEW - bug 267390: RFC 119 compliant file based discovery
https://bugs.eclipse.org/bugs/show_bug.cgi?id=267390
Diffstat (limited to 'compendium/bundles')
2 files changed, 60 insertions, 18 deletions
diff --git a/compendium/bundles/org.eclipse.ecf.osgi.services.distribution/src/org/eclipse/ecf/internal/osgi/services/distribution/Activator.java b/compendium/bundles/org.eclipse.ecf.osgi.services.distribution/src/org/eclipse/ecf/internal/osgi/services/distribution/Activator.java index 2de87369a..07b5d6da4 100644 --- a/compendium/bundles/org.eclipse.ecf.osgi.services.distribution/src/org/eclipse/ecf/internal/osgi/services/distribution/Activator.java +++ b/compendium/bundles/org.eclipse.ecf.osgi.services.distribution/src/org/eclipse/ecf/internal/osgi/services/distribution/Activator.java @@ -11,10 +11,10 @@ package org.eclipse.ecf.internal.osgi.services.distribution; import java.util.Dictionary; import java.util.Hashtable; +import org.eclipse.core.runtime.IAdapterManager; import org.eclipse.core.runtime.IStatus; import org.eclipse.ecf.core.IContainerManager; -import org.eclipse.ecf.core.util.LogHelper; -import org.eclipse.ecf.core.util.SystemLogService; +import org.eclipse.ecf.core.util.*; import org.eclipse.ecf.osgi.services.distribution.ECFServiceConstants; import org.osgi.framework.*; import org.osgi.framework.hooks.service.EventHook; @@ -41,6 +41,8 @@ public class Activator implements BundleActivator { private ServiceTracker logServiceTracker = null; private LogService logService = null; + private ServiceTracker adapterManagerTracker; + public static Activator getDefault() { return plugin; } @@ -180,6 +182,10 @@ public class Activator implements BundleActivator { logServiceTracker = null; logService = null; } + if (adapterManagerTracker != null) { + adapterManagerTracker.close(); + adapterManagerTracker = null; + } if (distributionProvider != null) { distributionProvider.dispose(); distributionProvider = null; @@ -197,4 +203,19 @@ public class Activator implements BundleActivator { return (IContainerManager) containerManagerTracker.getService(); } + public IAdapterManager getAdapterManager() { + // First, try to get the adapter manager via + if (adapterManagerTracker == null) { + adapterManagerTracker = new ServiceTracker(this.context, + IAdapterManager.class.getName(), null); + adapterManagerTracker.open(); + } + IAdapterManager adapterManager = (IAdapterManager) adapterManagerTracker + .getService(); + // Then, if the service isn't there, try to get from Platform class via + // PlatformHelper class + if (adapterManager == null) + adapterManager = PlatformHelper.getPlatformAdapterManager(); + return adapterManager; + } } diff --git a/compendium/bundles/org.eclipse.ecf.osgi.services.distribution/src/org/eclipse/ecf/internal/osgi/services/distribution/DiscoveredServiceTrackerImpl.java b/compendium/bundles/org.eclipse.ecf.osgi.services.distribution/src/org/eclipse/ecf/internal/osgi/services/distribution/DiscoveredServiceTrackerImpl.java index 93cb0d57d..1def49544 100644 --- a/compendium/bundles/org.eclipse.ecf.osgi.services.distribution/src/org/eclipse/ecf/internal/osgi/services/distribution/DiscoveredServiceTrackerImpl.java +++ b/compendium/bundles/org.eclipse.ecf.osgi.services.distribution/src/org/eclipse/ecf/internal/osgi/services/distribution/DiscoveredServiceTrackerImpl.java @@ -49,8 +49,12 @@ public class DiscoveredServiceTrackerImpl implements DiscoveredServiceTracker { ECFServicePublication.PROP_KEY_SERVICE_INTERFACE_VERSION, ECFServicePublication.PROP_KEY_SERVICE_PROPERTIES }); - /* (non-Javadoc) - * @see org.osgi.service.discovery.DiscoveredServiceTracker#serviceChanged(org.osgi.service.discovery.DiscoveredServiceNotification) + /* + * (non-Javadoc) + * + * @see + * org.osgi.service.discovery.DiscoveredServiceTracker#serviceChanged(org + * .osgi.service.discovery.DiscoveredServiceNotification) */ public void serviceChanged(DiscoveredServiceNotification notification) { if (notification == null) { @@ -85,10 +89,10 @@ public class DiscoveredServiceTrackerImpl implements DiscoveredServiceTracker { ServiceEndpointDescription sed) { // If the service endpoint description is not ECF's then we // don't process it - if (!(sed instanceof ECFServiceEndpointDescription)) { + ECFServiceEndpointDescription ecfSED = getECFserviceEndpointDescription(sed); + if (ecfSED == null) { return; } - ECFServiceEndpointDescription ecfSED = (ECFServiceEndpointDescription) sed; // Remove existing proxy service registrations that correspond to the // given serviceID ServiceRegistration[] proxyServiceRegistrations = removeProxyServiceRegistrations(ecfSED); @@ -97,8 +101,8 @@ public class DiscoveredServiceTrackerImpl implements DiscoveredServiceTracker { for (int i = 0; i < proxyServiceRegistrations.length; i++) { trace("handleDiscoveredServiceUnavailable", "proxyServiceRegistrations=" - + proxyServiceRegistrations[i] + ",serviceEndpointDesc=" - + ecfSED); + + proxyServiceRegistrations[i] + + ",serviceEndpointDesc=" + ecfSED); unregisterProxyServiceRegistration(proxyServiceRegistrations[i]); } } @@ -107,10 +111,10 @@ public class DiscoveredServiceTrackerImpl implements DiscoveredServiceTracker { private void handleDiscoveredServiceAvailable(ServiceEndpointDescription sed) { // If the service endpoint description is not ECF's then we // don't process it - if (!(sed instanceof ECFServiceEndpointDescription)) { + ECFServiceEndpointDescription ecfSED = getECFserviceEndpointDescription(sed); + if (ecfSED == null) { return; } - ECFServiceEndpointDescription ecfSED = (ECFServiceEndpointDescription) sed; ID endpointID = ecfSED.getECFEndpointID(); // Find RSCAs for the given description @@ -125,7 +129,8 @@ public class DiscoveredServiceTrackerImpl implements DiscoveredServiceTracker { if (cahs.length > 1) { logWarning("handleDiscoveredServiceAvailable", "Multiple remote service containers=" + Arrays.asList(cahs) - + " found for service endpoint description=" + ecfSED); + + " found for service endpoint description=" + + ecfSED); } // For all remote service container adapters // Get futureRemoteReferences...then create a thread @@ -148,6 +153,21 @@ public class DiscoveredServiceTrackerImpl implements DiscoveredServiceTracker { } } + private ECFServiceEndpointDescription getECFserviceEndpointDescription( + ServiceEndpointDescription aServiceEndpointDesc) { + ECFServiceEndpointDescription ecfSED; + if (!(aServiceEndpointDesc instanceof ECFServiceEndpointDescription)) { + IAdapterManager adapterManager = Activator.getDefault() + .getAdapterManager(); + ecfSED = (ECFServiceEndpointDescription) adapterManager.getAdapter( + aServiceEndpointDesc, ECFServiceEndpointDescription.class + .getName()); + } else { + ecfSED = (ECFServiceEndpointDescription) aServiceEndpointDesc; + } + return ecfSED; + } + private void processFutureForRemoteServiceReferences( final ECFServiceEndpointDescription sed, final IFuture futureRemoteReferences, @@ -216,8 +236,8 @@ public class DiscoveredServiceTrackerImpl implements DiscoveredServiceTracker { RemoteServiceRegistrations reg = (RemoteServiceRegistrations) discoveredRemoteServiceRegistrations .get(containerID); if (reg == null) { - reg = new RemoteServiceRegistrations(sed, ch.getContainer(), - ch.getRSCA(), + reg = new RemoteServiceRegistrations(sed, ch.getContainer(), ch + .getRSCA(), new RemoteServiceReferenceUnregisteredListener()); discoveredRemoteServiceRegistrations.put(containerID, reg); } @@ -330,9 +350,10 @@ public class DiscoveredServiceTrackerImpl implements DiscoveredServiceTracker { synchronized (discoveredRemoteServiceRegistrations) { if (findProxyServiceRegistration(sed)) { - logError("registerRemoteServiceReferences", "serviceEndpointDesc=" - + sed - + " previously registered locally...ignoring", null); + logError("registerRemoteServiceReferences", + "serviceEndpointDesc=" + sed + + " previously registered locally...ignoring", + null); return; } @@ -377,8 +398,8 @@ public class DiscoveredServiceTrackerImpl implements DiscoveredServiceTracker { ServiceRegistration registration = Activator.getDefault() .getContext().registerService(clazzes, proxy, properties); - addProxyServiceRegistration(sed, ch, - remoteReferences[i], registration); + addProxyServiceRegistration(sed, ch, remoteReferences[i], + registration); } catch (Exception e) { logError("registerRemoteServiceReferences", "Exception creating or registering remote reference " |