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.dom.impl;
10 import com.google.common.util.concurrent.CheckedFuture;
11 import org.opendaylight.controller.sal.core.api.model.SchemaService;
12 import org.opendaylight.controller.sal.core.api.model.YangTextSourceProvider;
13 import org.opendaylight.controller.sal.dom.broker.GlobalBundleScanningSchemaServiceImpl;
14 import org.opendaylight.yangtools.concepts.Delegator;
15 import org.opendaylight.yangtools.concepts.ListenerRegistration;
16 import org.opendaylight.yangtools.yang.model.api.Module;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
19 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
20 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
21 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
22 import org.osgi.framework.BundleContext;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
26 public final class SchemaServiceImplSingletonModule extends
27 org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractSchemaServiceImplSingletonModule {
29 private static final Logger LOG = LoggerFactory.getLogger(SchemaServiceImplSingletonModule.class);
31 BundleContext bundleContext;
33 public SchemaServiceImplSingletonModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
34 final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
35 super(identifier, dependencyResolver);
38 public SchemaServiceImplSingletonModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
39 final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
40 final SchemaServiceImplSingletonModule oldModule, final java.lang.AutoCloseable oldInstance) {
41 super(identifier, dependencyResolver, oldModule, oldInstance);
45 public boolean canReuseInstance(final AbstractSchemaServiceImplSingletonModule oldModule) {
49 public BundleContext getBundleContext() {
53 public void setBundleContext(final BundleContext bundleContext) {
54 this.bundleContext = bundleContext;
58 public void validate() {
63 public java.lang.AutoCloseable createInstance() {
64 return new GlobalSchemaServiceProxy(GlobalBundleScanningSchemaServiceImpl.getInstance());
67 private static class GlobalSchemaServiceProxy implements AutoCloseable, SchemaService, YangTextSourceProvider,
68 Delegator<SchemaService> {
69 private final GlobalBundleScanningSchemaServiceImpl delegate;
71 public GlobalSchemaServiceProxy(GlobalBundleScanningSchemaServiceImpl service) {
72 this.delegate = service;
77 // Intentional noop as the life-cycle is controlled via blueprint.
81 public void addModule(final Module arg0) {
82 delegate.addModule(arg0);
86 public SchemaContext getGlobalContext() {
87 return delegate.getGlobalContext();
91 public SchemaContext getSessionContext() {
92 return delegate.getSessionContext();
96 public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(final SchemaContextListener arg0) {
97 return delegate.registerSchemaContextListener(arg0);
101 public void removeModule(final Module arg0) {
102 delegate.removeModule(arg0);
106 public SchemaService getDelegate() {
111 public CheckedFuture<? extends YangTextSchemaSource, SchemaSourceException> getSource(
112 SourceIdentifier sourceIdentifier) {
113 return delegate.getSource(sourceIdentifier);