in cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationListener.java [139:208]
public boolean open() {
try (Syncro open = syncro.open()) {
if (_listenerService != null) {
return true;
}
if (containerState.bundleContext() == null) {
// this bundle was already removed
return false;
}
Dictionary<String, Object> properties = new Hashtable<>();
properties.put("name", toString());
properties.put(Constants.SERVICE_DESCRIPTION, "Aries CDI - Configuration Listener for " + containerState.bundle());
properties.put(Constants.SERVICE_VENDOR, "Apache Software Foundation");
_listenerService = containerState.bundleContext().registerService(
org.osgi.service.cm.ConfigurationListener.class, this, properties);
return next.map(next -> (Component)next).map(
component -> {
submit(component.openOp(), component::open).then(
s -> {
component.configurationTemplates().stream().filter(
ct -> Objects.nonNull(ct.pid)
).forEach(
template -> {
if (template.maximumCardinality == MaximumCardinality.ONE) {
containerState.findConfig(template.pid).ifPresent(
c -> processEvent(
component,
template,
new ConfigurationEvent(
containerState.caTracker().getServiceReference(),
ConfigurationEvent.CM_UPDATED,
null,
c.getPid()))
);
}
else {
containerState.findConfigs(template.pid, true).ifPresent(
arr -> Arrays.stream(arr).forEach(
c -> processEvent(
component,
template,
new ConfigurationEvent(
containerState.caTracker().getServiceReference(),
ConfigurationEvent.CM_UPDATED,
c.getFactoryPid(),
c.getPid()))
)
);
}
}
);
return s;
},
f -> {
_log.error(l -> l.error("CCR Failure during configuration start on {}", next, f.getFailure()));
error(f.getFailure());
}
);
return true;
}
).orElse(true);
}
}