use of org.apache.karaf.shell.api.console.Registry in project karaf by apache.
the class CommandExtension method updateState.
@SuppressWarnings("unchecked")
private synchronized void updateState(AggregateServiceTracker.State state) {
boolean wasSatisfied = manager != null;
boolean isSatisfied = state != null && state.isSatisfied();
String action;
if (wasSatisfied && isSatisfied) {
action = "Updating";
} else if (wasSatisfied) {
action = "Unregistering";
} else if (isSatisfied) {
action = "Registering";
} else {
return;
}
LOGGER.info("{} commands for bundle {}/{}", action, bundle.getSymbolicName(), bundle.getVersion());
if (wasSatisfied) {
for (Class clazz : classes) {
manager.unregister(clazz);
}
manager = null;
}
if (isSatisfied) {
Registry reg = new RegistryImpl(registry);
manager = new ManagerImpl(reg, registry);
reg.register(bundle.getBundleContext());
reg.register(manager);
for (Map.Entry<Class, Object> entry : state.getSingleServices().entrySet()) {
reg.register(entry.getValue());
}
for (final Map.Entry<Class, List> entry : state.getMultiServices().entrySet()) {
reg.register((Callable) entry::getValue, entry.getKey());
}
for (Class clazz : classes) {
manager.register(clazz);
}
}
}
Aggregations