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
1 /**
2 * Generated file
3
4 * Generated from: yang module name: openflow-provider-impl  yang module local name: openflow-provider-impl
5 * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
6 * Generated at: Wed Apr 02 16:59:36 PDT 2014
7 *
8 * Do not modify this file unless it is present under src/main directory
9 */
10 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326;
11
12 import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider;
13
14 import com.google.common.base.Objects;
15
16 /**
17 *
18 */
19 public final class ConfigurableOpenFlowProviderModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.common.config.impl.rev140326.AbstractConfigurableOpenFlowProviderModule {
20
21     private OpenflowPluginProvider pluginProvider;
22
23     /**
24      * @param identifier
25      * @param dependencyResolver
26      */
27     public ConfigurableOpenFlowProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
28         super(identifier, dependencyResolver);
29     }
30
31     /**
32      * @param identifier
33      * @param dependencyResolver
34      * @param oldModule
35      * @param oldInstance
36      */
37     public ConfigurableOpenFlowProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
38             ConfigurableOpenFlowProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
39
40         super(identifier, dependencyResolver, oldModule, oldInstance);
41     }
42
43     @Override
44     protected void customValidation() {
45         // Add custom validation for module attributes here.
46     }
47
48     @Override
49     public java.lang.AutoCloseable createInstance() {
50         pluginProvider =  new OpenflowPluginProvider();
51         pluginProvider.setBroker(getBindingAwareBrokerDependency());
52         pluginProvider.setSwitchConnectionProviders(getOpenflowSwitchConnectionProviderDependency());
53         pluginProvider.setRole(getRole());
54         pluginProvider.initialization();
55         return pluginProvider;
56     }
57
58     @Override
59     public boolean canReuseInstance(
60             AbstractConfigurableOpenFlowProviderModule oldModule) {
61         // we can reuse if only the role field changed
62         boolean noChangeExceptRole = true;
63         noChangeExceptRole &= getBindingAwareBrokerDependency().equals(oldModule.getBindingAwareBrokerDependency());
64         noChangeExceptRole &= getOpenflowSwitchConnectionProviderDependency().equals(oldModule.getOpenflowSwitchConnectionProviderDependency());
65         return noChangeExceptRole;
66     }
67
68     @Override
69     public AutoCloseable reuseInstance(AutoCloseable oldInstance) {
70         OpenflowPluginProvider recycled = (OpenflowPluginProvider) super.reuseInstance(oldInstance);
71         // change role if different
72         recycled.fireRoleChange(Objects.firstNonNull(getRole(), getRole()));
73
74         return recycled;
75     }
76 }