2 * Copyright (c) 2014 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
8 package org.opendaylight.controller.config.yang.md.sal.binding.impl;
10 import java.util.Collections;
13 import org.opendaylight.controller.config.api.DependencyResolver;
14 import org.opendaylight.controller.config.api.DependencyResolverFactory;
15 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
16 import org.opendaylight.controller.config.api.ModuleIdentifier;
17 import org.opendaylight.controller.config.spi.Module;
18 import org.osgi.framework.BundleContext;
23 public class RuntimeMappingModuleFactory extends
24 org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractRuntimeMappingModuleFactory {
26 private static RuntimeMappingModule SINGLETON = null;
27 private static ModuleIdentifier IDENTIFIER = new ModuleIdentifier(NAME, "runtime-mapping-singleton");
30 public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
31 throw new UnsupportedOperationException("Only default instance supported");
35 public Module createModule(String instanceName, DependencyResolver dependencyResolver,
36 DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
37 RuntimeMappingModule module = (RuntimeMappingModule) super.createModule(instanceName, dependencyResolver, old,
39 module.setBundleContext(bundleContext);
44 public Set<RuntimeMappingModule> getDefaultModules(DependencyResolverFactory dependencyResolverFactory,
45 BundleContext bundleContext) {
46 if (SINGLETON == null) {
47 DependencyResolver dependencyResolver = dependencyResolverFactory.createDependencyResolver(IDENTIFIER);
48 SINGLETON = new RuntimeMappingModule(IDENTIFIER, dependencyResolver);
49 SINGLETON.setBundleContext(bundleContext);
52 return Collections.singleton(SINGLETON);