Bug-2827: role switch proposal
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / yang / gen / v1 / urn / opendaylight / params / xml / ns / yang / openflow / common / config / impl / rev140326 / ConfigurableOpenFlowProviderModule.java
index fdd9470ba7b3d69d01a1117df17f70b2232d86b2..fbc87643b57460967695d5eee5baccd98911b2f1 100644 (file)
@@ -9,9 +9,11 @@
 */
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326;
 
+import javax.management.ObjectName;
+
 import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider;
 
-import com.google.common.base.Objects;
+import com.google.common.base.MoreObjects;
 
 /**
 *
@@ -60,8 +62,12 @@ public final class ConfigurableOpenFlowProviderModule extends org.opendaylight.y
             AbstractConfigurableOpenFlowProviderModule oldModule) {
         // we can reuse if only the role field changed
         boolean noChangeExceptRole = true;
-        noChangeExceptRole &= getBindingAwareBrokerDependency().equals(oldModule.getBindingAwareBrokerDependency());
-        noChangeExceptRole &= getOpenflowSwitchConnectionProviderDependency().equals(oldModule.getOpenflowSwitchConnectionProviderDependency());
+        noChangeExceptRole &= dependencyResolver.canReuseDependency(
+                getBindingAwareBroker(), bindingAwareBrokerJmxAttribute);
+        for (ObjectName ofSwitchProvider : getOpenflowSwitchConnectionProvider()) {
+            noChangeExceptRole &= dependencyResolver.canReuseDependency(
+                    ofSwitchProvider, openflowSwitchConnectionProviderJmxAttribute); 
+        }
         return noChangeExceptRole;
     }
 
@@ -69,7 +75,7 @@ public final class ConfigurableOpenFlowProviderModule extends org.opendaylight.y
     public AutoCloseable reuseInstance(AutoCloseable oldInstance) {
         OpenflowPluginProvider recycled = (OpenflowPluginProvider) super.reuseInstance(oldInstance);
         // change role if different
-        recycled.fireRoleChange(Objects.firstNonNull(getRole(), getRole()));
+        recycled.fireRoleChange(MoreObjects.firstNonNull(getRole(), getRole()));
 
         return recycled;
     }