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;
Logger logger = LoggerFactory
.getLogger(ComponentActivatorAbstractBase.class);
private DependencyManager dm;
- private ConcurrentMap<ImmutablePair<String, Object>, Component> dbInstances = (ConcurrentMap<ImmutablePair<String, Object>, Component>) new ConcurrentHashMap<ImmutablePair<String, Object>, Component>();
- private ConcurrentMap<Object, Component> dbGlobalInstances = (ConcurrentMap<Object, Component>) new ConcurrentHashMap<Object, Component>();
+ private ConcurrentMap<ImmutablePair<String, Object>, Component> dbInstances = new ConcurrentHashMap<ImmutablePair<String, Object>, Component>();
+ private ConcurrentMap<Object, Component> dbGlobalInstances = new ConcurrentHashMap<Object, Component>();
/**
- * 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
@Override
public void stopped(Component component) {
+ // do nothing
+ }
+
+ @Override
+ public void stopping(Component component) {
if (component == null) {
return;
}
{ Component.class }, {} }, new Object[][] { { component },
{} });
}
-
- @Override
- public void stopping(Component component) {
- // do nothing
- }
}
/**
//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<String, String> serviceProps = c
.getServiceProperties();
if (serviceProps != null) {
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);
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();
}
}
}
}
-
+
// Register with OSGi the provider for the service IContainerAware
context.registerService(
IContainerAware.class.getName(), this, null);