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;
BundleActivator, IContainerAware {
Logger logger = LoggerFactory
.getLogger(ComponentActivatorAbstractBase.class);
- private ServiceRegistration containerAwareRegistration;
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>();
public void containerCreate(String containerName) {
try {
Object[] imps = getImplementations();
- logger.trace("Creating instance " + containerName);
+ logger.trace("Creating instance {}", containerName);
if (imps != null) {
for (int i = 0; i < imps.length; i++) {
ImmutablePair<String, Object> key = new ImmutablePair<String, Object>(
// Set the implementation so the component can manage
// its lifecycle
if (c.getService() == null) {
- logger
- .trace("Setting implementation to:"
- + imps[i]);
+ logger.trace("Setting implementation to: {}",
+ imps[i]);
c.setImplementation(imps[i]);
}
public void containerDestroy(String containerName) {
try {
Object[] imps = getImplementations();
- logger.trace("Destroying instance " + containerName);
+ logger.trace("Destroying instance {}", containerName);
if (imps != null) {
for (int i = 0; i < imps.length; i++) {
ImmutablePair<String, Object> key = new ImmutablePair<String, Object>(
// Set the implementation so the component
// can manage its lifesycle
if (c.getService() == null) {
- logger.trace("Setting implementation to:"
- + imps[i]);
+ logger.trace("Setting implementation to: {}",
+ imps[i]);
c.setImplementation(imps[i]);
}
}
}
}
-
+
// 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
try {
Component c = this.dbInstances.get(key);
if (c != null) {
- logger.trace("Remove component on container:"
- + key.getLeft() + " Object:" + key.getRight());
+ logger.trace("Remove component on container: {} Object: {}",
+ key.getLeft(), key.getRight());
this.dm.remove(c);
}
} catch (Exception nex) {
try {
Component c = this.dbGlobalInstances.get(key);
if (c != null) {
- logger.trace("Remove component for Object:" + key);
+ logger.trace("Remove component for Object: {}" , key);
this.dm.remove(c);
}
} catch (Exception nex) {