HostTracker hosts DB key scheme implementation
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / config / yang / md / sal / binding / impl / BindingBrokerImplSingletonModuleFactory.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.config.yang.md.sal.binding.impl;
10
11 import org.opendaylight.controller.config.api.DependencyResolver;
12 import org.opendaylight.controller.config.api.DependencyResolverFactory;
13 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
14 import org.opendaylight.controller.config.api.ModuleIdentifier;
15 import org.opendaylight.controller.config.spi.Module;
16 import org.osgi.framework.BundleContext;
17
18 import java.util.Collections;
19 import java.util.Set;
20
21 /**
22 *
23 */
24 public class BindingBrokerImplSingletonModuleFactory extends
25         org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplSingletonModuleFactory {
26
27     private static final String SINGLETON_NAME = "binding-broker-singleton";
28     public static ModuleIdentifier SINGLETON_IDENTIFIER = new ModuleIdentifier(NAME, SINGLETON_NAME);
29
30     @Override
31     public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
32         throw new UnsupportedOperationException("Only default instance supported.");
33     }
34
35     @Override
36     public Module createModule(String instanceName, DependencyResolver dependencyResolver,
37             DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
38         Module instance = super.createModule(instanceName, dependencyResolver, old, bundleContext);
39         ((BindingBrokerImplSingletonModule)instance).setBundleContext(bundleContext);
40         return instance;
41     }
42
43     @Override
44     public Set<BindingBrokerImplSingletonModule> getDefaultModules(DependencyResolverFactory dependencyResolverFactory,
45             BundleContext bundleContext) {
46
47         DependencyResolver dependencyResolver = dependencyResolverFactory
48                 .createDependencyResolver(SINGLETON_IDENTIFIER);
49         BindingBrokerImplSingletonModule instance = new BindingBrokerImplSingletonModule(SINGLETON_IDENTIFIER,
50                 dependencyResolver);
51         instance.setBundleContext(bundleContext);
52
53         return Collections.singleton(instance);
54     }
55
56 }