Repository: karaf-cellar Updated Branches: refs/heads/master 7a598b285 -> 7ec918a08
Improve jclouds service registration Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/a27f5149 Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/a27f5149 Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/a27f5149 Branch: refs/heads/master Commit: a27f5149974f68844ea69f8a2a32d35e4d980cb2 Parents: 7a598b2 Author: Jean-Baptiste Onofré <[email protected]> Authored: Sun Jan 18 19:27:18 2015 +0100 Committer: Jean-Baptiste Onofré <[email protected]> Committed: Sun Jan 18 19:27:18 2015 +0100 ---------------------------------------------------------------------- .../main/java/org/apache/karaf/cellar/cloud/Activator.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/a27f5149/cloud/src/main/java/org/apache/karaf/cellar/cloud/Activator.java ---------------------------------------------------------------------- diff --git a/cloud/src/main/java/org/apache/karaf/cellar/cloud/Activator.java b/cloud/src/main/java/org/apache/karaf/cellar/cloud/Activator.java index 8c020cb..b8f253a 100644 --- a/cloud/src/main/java/org/apache/karaf/cellar/cloud/Activator.java +++ b/cloud/src/main/java/org/apache/karaf/cellar/cloud/Activator.java @@ -16,6 +16,7 @@ package org.apache.karaf.cellar.cloud; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; +import org.osgi.framework.ServiceRegistration; import org.osgi.service.cm.ManagedServiceFactory; import java.util.Hashtable; @@ -25,17 +26,21 @@ import java.util.Hashtable; */ public class Activator implements BundleActivator { + private ServiceRegistration serviceRegistration; + @Override public void start(BundleContext context) throws Exception { Hashtable<String, Object> properties = new Hashtable<String, Object>(); properties.put(Constants.SERVICE_PID, "org.apache.karaf.cellar.cloud"); BlobStoreDiscoveryServiceFactory blobStoreDiscoveryServiceFactory = new BlobStoreDiscoveryServiceFactory(context); - context.registerService(ManagedServiceFactory.class.getName(), blobStoreDiscoveryServiceFactory, properties); + serviceRegistration = context.registerService(ManagedServiceFactory.class.getName(), blobStoreDiscoveryServiceFactory, properties); } @Override public void stop(BundleContext context) throws Exception { - // nothing to do + if (serviceRegistration != null) { + serviceRegistration.unregister(); + } } } \ No newline at end of file
