X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fsal%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcore%2FComponentActivatorAbstractBase.java;h=0cd1612808b4a67e8c0eb38c0dec013e4090dee3;hp=88a829ba0464ab7c57e2c0d320666df78d2a7175;hb=da09b89e760719b3b5bb9f437fe3cf17726e547b;hpb=bb3842c34d5c56d9aa37c02e9eea6128a2f6d86b diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/ComponentActivatorAbstractBase.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/ComponentActivatorAbstractBase.java index 88a829ba04..0cd1612808 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/ComponentActivatorAbstractBase.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/ComponentActivatorAbstractBase.java @@ -32,7 +32,6 @@ import org.apache.felix.dm.DependencyManager; import org.apache.felix.dm.ServiceDependency; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,24 +44,25 @@ abstract public class ComponentActivatorAbstractBase implements BundleActivator, IContainerAware { Logger logger = LoggerFactory .getLogger(ComponentActivatorAbstractBase.class); - private ServiceRegistration containerAwareRegistration; private DependencyManager dm; - private ConcurrentMap, Component> dbInstances = (ConcurrentMap, Component>) new ConcurrentHashMap, Component>(); - private ConcurrentMap dbGlobalInstances = (ConcurrentMap) new ConcurrentHashMap(); + private ConcurrentMap, Component> dbInstances = new ConcurrentHashMap, Component>(); + private ConcurrentMap dbGlobalInstances = new ConcurrentHashMap(); /** - * Abstract method that MUST be implemented by the derived class - * that wants to activate the Component bundle in a container. Here - * customization for the component are expected + * Method that should be overriden by the derived class for customization + * during activation of the Component bundle in a container. */ - abstract protected void init(); + protected void init() { + + } /** - * Abstract method that MUST be implemented by the derived class - * that wants to DE-activate the Component bundle in a container. Here - * customization for the component are expected + * Method that should be overriden by the derived class for customization + * during DE-activation of the Component bundle in a container. */ - abstract protected void destroy(); + public void destroy() { + + } /** * Method which tells how many implementations are supported by @@ -154,6 +154,11 @@ abstract public class ComponentActivatorAbstractBase implements @Override public void stopped(Component component) { + // do nothing + } + + @Override + public void stopping(Component component) { if (component == null) { return; } @@ -162,11 +167,6 @@ abstract public class ComponentActivatorAbstractBase implements { Component.class }, {} }, new Object[][] { { component }, {} }); } - - @Override - public void stopping(Component component) { - // do nothing - } } /** @@ -201,6 +201,7 @@ abstract public class ComponentActivatorAbstractBase implements //Set the service properties to include the containerName //in the service, that is fundamental for supporting //multiple services just distinguished via a container + @SuppressWarnings("unchecked") Dictionary serviceProps = c .getServiceProperties(); if (serviceProps != null) { @@ -252,6 +253,11 @@ abstract public class ComponentActivatorAbstractBase implements containerName, imps[i]); Component c = this.dbInstances.get(key); if (c != null) { + if (c.getService() != null) { + c.invokeCallbackMethod(new Object[] { c.getService() }, "containerStop", + new Class[][] {{ Component.class}, {} }, + new Object[][] { {c}, {} }); + } // Now remove the component from dependency manager, // which will implicitely stop it first this.dm.remove(c); @@ -287,7 +293,7 @@ abstract public class ComponentActivatorAbstractBase implements StringBuffer buffer = new StringBuffer(); for (int i = 0; i < stack.length; i++) { - buffer.append("\n\t" + stack[i].toString()); + buffer.append("\n\t").append(stack[i].toString()); } return buffer.toString(); } @@ -358,7 +364,7 @@ abstract public class ComponentActivatorAbstractBase implements } // Register with OSGi the provider for the service IContainerAware - this.containerAwareRegistration = context.registerService( + context.registerService( IContainerAware.class.getName(), this, null); // Now call the derived class init function