2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.config.yang.md.sal.binding.impl;
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;
18 import java.util.Collections;
24 public class BindingBrokerImplSingletonModuleFactory extends
25 org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplSingletonModuleFactory {
27 private static final String SINGLETON_NAME = "binding-broker-singleton";
28 public static ModuleIdentifier SINGLETON_IDENTIFIER = new ModuleIdentifier(NAME, SINGLETON_NAME);
31 public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
32 throw new UnsupportedOperationException("Only default instance supported.");
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);
44 public Set<BindingBrokerImplSingletonModule> getDefaultModules(DependencyResolverFactory dependencyResolverFactory,
45 BundleContext bundleContext) {
47 DependencyResolver dependencyResolver = dependencyResolverFactory
48 .createDependencyResolver(SINGLETON_IDENTIFIER);
49 BindingBrokerImplSingletonModule instance = new BindingBrokerImplSingletonModule(SINGLETON_IDENTIFIER,
51 instance.setBundleContext(bundleContext);
53 return Collections.singleton(instance);