diff options
author | slewis | 2009-02-04 06:55:20 +0000 |
---|---|---|
committer | slewis | 2009-02-04 06:55:20 +0000 |
commit | 05a7c2e45499c3e1df95ddca6442dfe227b2230d (patch) | |
tree | bda5d368b10edce122e4013d7270dc659332b2ed /compendium/bundles/org.eclipse.ecf.osgi.services.discovery | |
parent | 0a9b498cc8165cf95e6856ac0f5508b821239bb4 (diff) | |
download | org.eclipse.ecf-05a7c2e45499c3e1df95ddca6442dfe227b2230d.tar.gz org.eclipse.ecf-05a7c2e45499c3e1df95ddca6442dfe227b2230d.tar.xz org.eclipse.ecf-05a7c2e45499c3e1df95ddca6442dfe227b2230d.zip |
Added wait for discovery service
Diffstat (limited to 'compendium/bundles/org.eclipse.ecf.osgi.services.discovery')
-rw-r--r-- | compendium/bundles/org.eclipse.ecf.osgi.services.discovery/src/org/eclipse/ecf/internal/osgi/services/discovery/Activator.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/compendium/bundles/org.eclipse.ecf.osgi.services.discovery/src/org/eclipse/ecf/internal/osgi/services/discovery/Activator.java b/compendium/bundles/org.eclipse.ecf.osgi.services.discovery/src/org/eclipse/ecf/internal/osgi/services/discovery/Activator.java index bf552b3f7..2abd5afb4 100644 --- a/compendium/bundles/org.eclipse.ecf.osgi.services.discovery/src/org/eclipse/ecf/internal/osgi/services/discovery/Activator.java +++ b/compendium/bundles/org.eclipse.ecf.osgi.services.discovery/src/org/eclipse/ecf/internal/osgi/services/discovery/Activator.java @@ -23,6 +23,8 @@ public class Activator implements BundleActivator { public static final String PLUGIN_ID = "org.eclipse.ecf.osgi.services.discovery"; + private static final long DISCOVERY_TIMEOUT = 0; + private ServiceTracker servicePublicationTracker; private ServiceTracker discoveryServiceTracker; private ServiceTracker discoveredServiceTrackerTracker; @@ -46,6 +48,7 @@ public class Activator implements BundleActivator { plugin = this; this.context = ctxt; IDiscoveryService discovery = getDiscoveryService(); + if (discovery == null) throw new NullPointerException("discovery service cannot be found"); URL bundleURL = ctxt.getBundle().getEntry("/"); String bundleURLString = bundleURL.toExternalForm(); if (!bundleURLString.endsWith("/")) @@ -65,13 +68,13 @@ public class Activator implements BundleActivator { return servicePublicationHandler; } - public IDiscoveryService getDiscoveryService() { + public IDiscoveryService getDiscoveryService() throws InterruptedException { if (discoveryServiceTracker == null) { discoveryServiceTracker = new ServiceTracker(this.context, IDiscoveryService.class.getName(), null); discoveryServiceTracker.open(); } - return (IDiscoveryService) discoveryServiceTracker.getService(); + return (IDiscoveryService) discoveryServiceTracker.waitForService(DISCOVERY_TIMEOUT); } public ServiceReference[] getDiscoveredServiceTrackerReferences() { |