X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fmanager%2Fimpl%2Fosgi%2FBeanToOsgiServiceManager.java;h=51f99403148ba7b40301e52b63b391ae98c0134e;hb=0e74e5866c506da072cae3a2897335df7170f958;hp=3d93a9df7dee72bb450af215bd7dea97f24199a5;hpb=f2ea11b45c819121a3d6fb8914172148ac3994a3;p=controller.git diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BeanToOsgiServiceManager.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BeanToOsgiServiceManager.java index 3d93a9df7d..51f9940314 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BeanToOsgiServiceManager.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BeanToOsgiServiceManager.java @@ -7,7 +7,7 @@ */ package org.opendaylight.controller.config.manager.impl.osgi; -import static com.google.common.base.Preconditions.checkState; +import com.google.common.base.Preconditions; import java.util.Dictionary; import java.util.HashSet; import java.util.Hashtable; @@ -40,13 +40,6 @@ public class BeanToOsgiServiceManager { return new OsgiRegistration(instance, moduleIdentifier, bundleContext, serviceNamesToAnnotations); } - private static Dictionary createProps(String serviceName) { - Hashtable result = new Hashtable<>(); - result.put(SERVICE_NAME_OSGI_PROP, serviceName); - return result; - } - - public static class OsgiRegistration implements AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(OsgiRegistration.class); @@ -79,7 +72,7 @@ public class BeanToOsgiServiceManager { continue; } - checkState(requiredInterface.isInstance(instance), instance.getClass().getName() + + Preconditions.checkState(requiredInterface.isInstance(instance), instance.getClass().getName() + " instance should implement " + requiredInterface.getName()); Dictionary propertiesForOsgi = createProps(entry.getValue()); ServiceRegistration serviceRegistration = bundleContext @@ -103,8 +96,8 @@ public class BeanToOsgiServiceManager { public synchronized void updateRegistrations(Map newAnnotationMapping, BundleContext bundleContext, AutoCloseable newInstance) { - boolean notEquals = this.instance != newInstance; - notEquals |= newAnnotationMapping.equals(serviceNamesToAnnotations) == false; + boolean notEquals = !this.instance.equals(newInstance); + notEquals |= !newAnnotationMapping.equals(serviceNamesToAnnotations); if (notEquals) { // FIXME: changing from old state to new state can be improved by computing the diff LOG.debug("Detected change in service registrations for {}: old: {}, new: {}", moduleIdentifier, @@ -116,5 +109,11 @@ public class BeanToOsgiServiceManager { serviceRegistrations.addAll(newRegs); } } + + private static Dictionary createProps(String serviceName) { + Hashtable result = new Hashtable<>(); + result.put(SERVICE_NAME_OSGI_PROP, serviceName); + return result; + } } }