import java.util.Dictionary;
import java.util.Hashtable;
import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.aries.blueprint.ComponentDefinitionRegistry;
import org.apache.aries.blueprint.ComponentDefinitionRegistryProcessor;
import org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder;
private boolean restartDependentsOnUpdates;
private boolean useDefaultForReferenceTypes;
- public void setBundle(Bundle bundle) {
+ public void setBundle(final Bundle bundle) {
this.bundle = bundle;
}
- public void setBlueprintContainerRestartService(BlueprintContainerRestartService restartService) {
+ public void setBlueprintContainerRestartService(final BlueprintContainerRestartService restartService) {
this.blueprintContainerRestartService = restartService;
}
- public void setRestartDependentsOnUpdates(boolean restartDependentsOnUpdates) {
+ public void setRestartDependentsOnUpdates(final boolean restartDependentsOnUpdates) {
this.restartDependentsOnUpdates = restartDependentsOnUpdates;
}
- public void setUseDefaultForReferenceTypes(boolean useDefaultForReferenceTypes) {
+ public void setUseDefaultForReferenceTypes(final boolean useDefaultForReferenceTypes) {
this.useDefaultForReferenceTypes = useDefaultForReferenceTypes;
}
}
@Override
- public void process(ComponentDefinitionRegistry registry) {
+ public void process(final ComponentDefinitionRegistry registry) {
LOG.debug("{}: In process", logName());
for (String name : registry.getComponentDefinitionNames()) {
}
}
- private void processServiceReferenceMetadata(MutableServiceReferenceMetadata serviceRef) {
+ private void processServiceReferenceMetadata(final MutableServiceReferenceMetadata serviceRef) {
if (!useDefaultForReferenceTypes) {
return;
}
}
}
- private void processMutableBeanMetadata(MutableBeanMetadata bean) {
+ private void processMutableBeanMetadata(final MutableBeanMetadata bean) {
if (restartDependentsOnUpdates && bean.getRuntimeClass() != null
&& AbstractPropertyPlaceholder.class.isAssignableFrom(bean.getRuntimeClass())) {
LOG.debug("{}: Found PropertyPlaceholder bean: {}, runtime {}", logName(), bean.getId(),
// Register a ManagedService so we get updates from the ConfigAdmin when the cfg file corresponding
// to the persistentId changes.
final ManagedService managedService = new ManagedService() {
- private volatile boolean initialUpdate = true;
+ private final AtomicBoolean initialUpdate = new AtomicBoolean(true);
+ private volatile Dictionary<String, ?> previousProperties;
@Override
- public void updated(Dictionary<String, ?> properties) {
+ public void updated(final Dictionary<String, ?> properties) {
LOG.debug("{}: ManagedService updated for persistentId {}, properties: {}, initialUpdate: {}",
logName(), persistentId, properties, initialUpdate);
// The first update occurs when the service is registered so ignore it as we want subsequent
// updates when it changes. The ConfigAdmin will send an update even if the cfg file doesn't
// yet exist.
- if (initialUpdate) {
- initialUpdate = false;
- } else {
+ if (!initialUpdate.compareAndSet(true, false) && !Objects.equals(previousProperties, properties)) {
blueprintContainerRestartService.restartContainerAndDependents(bundle);
}
+
+ previousProperties = properties;
}
};