package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326;
import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider;
-import org.osgi.framework.BundleContext;
+
+import com.google.common.base.Objects;
/**
*
public final class ConfigurableOpenFlowProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326.AbstractConfigurableOpenFlowProviderModule {
private OpenflowPluginProvider pluginProvider;
- private BundleContext bundleContext;
/**
* @param identifier
@Override
public java.lang.AutoCloseable createInstance() {
pluginProvider = new OpenflowPluginProvider();
- pluginProvider.setContext(bundleContext);
pluginProvider.setBroker(getBindingAwareBrokerDependency());
pluginProvider.setSwitchConnectionProviders(getOpenflowSwitchConnectionProviderDependency());
+ pluginProvider.setRole(getRole());
pluginProvider.initialization();
return pluginProvider;
}
- /**
- * @param bundleContext the bundleContext to set, see {@link OpenflowPluginProvider#setContext(BundleContext)}
- *
- * @deprecated we should avoid osgi specific stuff .. once,
- */
- @Deprecated
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
+ @Override
+ public boolean canReuseInstance(
+ AbstractConfigurableOpenFlowProviderModule oldModule) {
+ // we can reuse if only the role field changed
+ boolean noChangeExceptRole = true;
+ noChangeExceptRole &= getBindingAwareBrokerDependency().equals(oldModule.getBindingAwareBrokerDependency());
+ noChangeExceptRole &= getOpenflowSwitchConnectionProviderDependency().equals(oldModule.getOpenflowSwitchConnectionProviderDependency());
+ return noChangeExceptRole;
+ }
+
+ @Override
+ public AutoCloseable reuseInstance(AutoCloseable oldInstance) {
+ OpenflowPluginProvider recycled = (OpenflowPluginProvider) super.reuseInstance(oldInstance);
+ // change role if different
+ recycled.fireRoleChange(Objects.firstNonNull(getRole(), getRole()));
+
+ return recycled;
}
}