Merge "Prevent ConfigPusher from killing its thread"
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / config / yang / md / sal / dom / impl / SchemaServiceImplSingletonModuleFactory.java
1 /*
2  * Copyright (c) 2014 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 package org.opendaylight.controller.config.yang.md.sal.dom.impl;
9
10 import java.util.Collections;
11 import java.util.Set;
12
13 import org.opendaylight.controller.config.api.DependencyResolver;
14 import org.opendaylight.controller.config.api.DependencyResolverFactory;
15 import org.opendaylight.controller.config.api.ModuleIdentifier;
16 import org.opendaylight.controller.config.spi.Module;
17 import org.osgi.framework.BundleContext;
18
19 /**
20 *
21 */
22 public class SchemaServiceImplSingletonModuleFactory extends
23         org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractSchemaServiceImplSingletonModuleFactory {
24
25     private static final ModuleIdentifier IDENTIFIER = new ModuleIdentifier(NAME, "yang-schema-service");
26     public static SchemaServiceImplSingletonModule SINGLETON;
27
28     @Override
29     public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
30         throw new UnsupportedOperationException("Only default instance supported.");
31     }
32
33     @Override
34     public Set<SchemaServiceImplSingletonModule> getDefaultModules(DependencyResolverFactory dependencyResolverFactory,
35             BundleContext bundleContext) {
36         DependencyResolver dependencyResolver = dependencyResolverFactory.createDependencyResolver(IDENTIFIER);
37
38         if (SINGLETON == null) {
39             SINGLETON = new SchemaServiceImplSingletonModule(IDENTIFIER, dependencyResolver);
40             SINGLETON.setBundleContext(bundleContext);
41         }
42         return Collections.singleton(SINGLETON);
43     }
44 }