Deprecate md-sal config modules
[controller.git] / opendaylight / md-sal / sal-dom-broker-config / src / main / java / org / opendaylight / controller / config / yang / md / sal / dom / impl / SchemaServiceImplSingletonModule.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 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;
25
26 /**
27  * @deprecated Replaced by blueprint wiring
28  */
29 @Deprecated
30 public final class SchemaServiceImplSingletonModule extends
31 org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractSchemaServiceImplSingletonModule {
32
33     private static final Logger LOG = LoggerFactory.getLogger(SchemaServiceImplSingletonModule.class);
34
35     BundleContext bundleContext;
36
37     public SchemaServiceImplSingletonModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
38             final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
39         super(identifier, dependencyResolver);
40     }
41
42     public SchemaServiceImplSingletonModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
43             final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
44             final SchemaServiceImplSingletonModule oldModule, final java.lang.AutoCloseable oldInstance) {
45         super(identifier, dependencyResolver, oldModule, oldInstance);
46     }
47
48     @Override
49     public boolean canReuseInstance(final AbstractSchemaServiceImplSingletonModule oldModule) {
50         return true;
51     }
52
53     public BundleContext getBundleContext() {
54         return bundleContext;
55     }
56
57     public void setBundleContext(final BundleContext bundleContext) {
58         this.bundleContext = bundleContext;
59     }
60
61     @Override
62     public void validate() {
63         super.validate();
64     }
65
66     @Override
67     public java.lang.AutoCloseable createInstance() {
68         return new GlobalSchemaServiceProxy(GlobalBundleScanningSchemaServiceImpl.getInstance());
69     }
70
71     private static class GlobalSchemaServiceProxy implements AutoCloseable, SchemaService, YangTextSourceProvider,
72             Delegator<SchemaService> {
73         private final GlobalBundleScanningSchemaServiceImpl delegate;
74
75         public GlobalSchemaServiceProxy(GlobalBundleScanningSchemaServiceImpl service) {
76             this.delegate = service;
77         }
78
79         @Override
80         public void close() {
81             // Intentional noop as the life-cycle is controlled via blueprint.
82         }
83
84         @Override
85         public void addModule(final Module arg0) {
86             delegate.addModule(arg0);
87         }
88
89         @Override
90         public SchemaContext getGlobalContext() {
91             return delegate.getGlobalContext();
92         }
93
94         @Override
95         public SchemaContext getSessionContext() {
96             return delegate.getSessionContext();
97         }
98
99         @Override
100         public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(final SchemaContextListener arg0) {
101             return delegate.registerSchemaContextListener(arg0);
102         }
103
104         @Override
105         public void removeModule(final Module arg0) {
106             delegate.removeModule(arg0);
107         }
108
109         @Override
110         public SchemaService getDelegate() {
111             return delegate;
112         }
113
114         @Override
115         public CheckedFuture<? extends YangTextSchemaSource, SchemaSourceException> getSource(
116                 SourceIdentifier sourceIdentifier) {
117             return delegate.getSource(sourceIdentifier);
118         }
119     }
120 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.