Fixed major sonar warnings in Binding Aware Broker
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / config / yang / md / sal / binding / impl / RuntimeMappingModuleFactory.java
1 /**
2  * Generated file
3
4  * Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: runtime-generated-mapping
5  * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
6  * Generated at: Wed Nov 20 18:20:19 CET 2013
7  *
8  * Do not modify this file unless it is present under src/main directory
9  */
10 package org.opendaylight.controller.config.yang.md.sal.binding.impl;
11
12 import java.util.Collections;
13 import java.util.Set;
14
15 import org.opendaylight.controller.config.api.DependencyResolver;
16 import org.opendaylight.controller.config.api.DependencyResolverFactory;
17 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
18 import org.opendaylight.controller.config.api.ModuleIdentifier;
19 import org.opendaylight.controller.config.spi.Module;
20 import org.osgi.framework.BundleContext;
21
22 /**
23 *
24 */
25 public class RuntimeMappingModuleFactory extends
26         org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractRuntimeMappingModuleFactory {
27
28     private static RuntimeMappingModule SINGLETON = null;
29     private static ModuleIdentifier IDENTIFIER = new ModuleIdentifier(NAME, "runtime-mapping-singleton");
30
31     @Override
32     public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
33         throw new UnsupportedOperationException("Only default instance supported");
34     }
35
36     @Override
37     public Module createModule(String instanceName, DependencyResolver dependencyResolver,
38             DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
39         RuntimeMappingModule module = (RuntimeMappingModule) super.createModule(instanceName, dependencyResolver, old,
40                 bundleContext);
41         module.setBundleContext(bundleContext);
42         return module;
43     }
44
45     @Override
46     public Set<RuntimeMappingModule> getDefaultModules(DependencyResolverFactory dependencyResolverFactory,
47             BundleContext bundleContext) {
48         if (SINGLETON == null) {
49             DependencyResolver dependencyResolver = dependencyResolverFactory.createDependencyResolver(IDENTIFIER);
50             SINGLETON = new RuntimeMappingModule(IDENTIFIER, dependencyResolver);
51             SINGLETON.setBundleContext(bundleContext);
52         }
53
54         return Collections.singleton(SINGLETON);
55     }
56
57 }