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;
import org.apache.aries.blueprint.mutable.MutableBeanMetadata;
import org.apache.aries.blueprint.mutable.MutableServiceReferenceMetadata;
import org.apache.aries.util.AriesFrameworkUtil;
+import org.gaul.modernizer_maven_annotations.SuppressModernizer;
import org.opendaylight.controller.blueprint.BlueprintContainerRestartService;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
}
}
+ @SuppressModernizer
private void registerManagedService(final String persistentId) {
// 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(final Dictionary<String, ?> properties) {
// 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;
}
};
props.put(Constants.SERVICE_PID, persistentId);
props.put(Constants.BUNDLE_SYMBOLICNAME, bundle.getSymbolicName());
props.put(Constants.BUNDLE_VERSION, bundle.getHeaders().get(Constants.BUNDLE_VERSION));
- managedServiceRegs.add(bundle.getBundleContext().registerService(ManagedService.class.getName(),
- managedService, props));
+ managedServiceRegs.add(bundle.getBundleContext().registerService(ManagedService.class, managedService, props));
}
private String logName() {