Bump odlparent to 6.0.0
[controller.git] / opendaylight / blueprint / src / main / java / org / opendaylight / controller / blueprint / ext / ComponentProcessor.java
index 97f2fd2b0c92f8bbf59f15d900f8601fd17fc07e..2f0709f6af8fae04096bbb963c2baf5134d89134 100644 (file)
@@ -12,12 +12,15 @@ import java.util.ArrayList;
 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;
@@ -129,11 +132,13 @@ public class ComponentProcessor implements ComponentDefinitionRegistryProcessor
         }
     }
 
+    @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) {
@@ -143,11 +148,11 @@ public class ComponentProcessor implements ComponentDefinitionRegistryProcessor
                 // 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;
             }
         };
 
@@ -155,8 +160,7 @@ public class ComponentProcessor implements ComponentDefinitionRegistryProcessor
         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() {