{
this.ctx = ctx;
ServiceReference ref = ctx.getServiceReference(PackageAdmin.class.getName());
pkgAdm = PackageAdmin.class.cast(ctx.getService(ref));
BundleTracker bt = new BundleTracker(ctx, Bundle.INSTALLED | Bundle.RESOLVED | Bundle.STARTING | Bundle.ACTIVE, new BundleTrackerCustomizer() {
@Override
public void modifiedBundle(Bundle bundle, BundleEvent bundleEvent, Object o) {
}
@Override
public Object addingBundle(Bundle bundle, BundleEvent bundleEvent) {
String key = makeKey(bundle);
name2Id.put(key, bundle.getBundleId());
if (logger != null && logger.isLoggable(Level.FINER)) {
logger.log(Level.FINER, "BundleTracker.addingBundle BUNDLE " + key + " ==> " + bundle.getBundleId() + " for " + bundle.getSymbolicName());
}
return null;
}
@Override
public void removedBundle(Bundle bundle, BundleEvent bundleEvent, Object o) {
String key = makeKey(bundle);
Long bundleID = name2Id.remove(key);
if (logger.isLoggable(Level.FINER)) {
logger.log(Level.FINER, "BundleTracker.removedBundle BUNDLE " + key + " ==> " + bundle.getSymbolicName());
}
if (bundleID == null) {
logger.log(Level.WARNING, NULL_BUNDLE, key);
}
}
/*
@Override
public Object addingBundle(Bundle bundle, BundleEvent event) {
System.out.println("ADDING BUNDLE ==> " + bundle.getSymbolicName());
return super.addingBundle(bundle, event); //To change body of overridden methods use File | Settings | File Templates.
}
@Override
public void removedBundle(Bundle bundle, BundleEvent event, Object object) {
System.out.println("REMOVING BUNDLE ==> " + bundle.getSymbolicName());
super.removedBundle(bundle, event, object); //To change body of overridden methods use File | Settings | File Templates.
}
*/
});
bt.open();
}