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.ListenableFuture;
11 import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
12 import org.opendaylight.controller.sal.core.api.model.SchemaService;
13 import org.opendaylight.controller.sal.core.api.model.YangTextSourceProvider;
14 import org.opendaylight.yangtools.concepts.ListenerRegistration;
15 import org.opendaylight.yangtools.yang.model.api.Module;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
18 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
19 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
20 import org.osgi.framework.BundleContext;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
27 * @deprecated Replaced by blueprint wiring
30 public final class SchemaServiceImplSingletonModule extends AbstractSchemaServiceImplSingletonModule {
32 private static final Logger LOG = LoggerFactory.getLogger(SchemaServiceImplSingletonModule.class);
34 BundleContext bundleContext;
36 public SchemaServiceImplSingletonModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
37 final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
38 super(identifier, dependencyResolver);
41 public SchemaServiceImplSingletonModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
42 final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
43 final SchemaServiceImplSingletonModule oldModule, final java.lang.AutoCloseable oldInstance) {
44 super(identifier, dependencyResolver, oldModule, oldInstance);
48 public boolean canReuseInstance(final AbstractSchemaServiceImplSingletonModule oldModule) {
52 public BundleContext getBundleContext() {
56 public void setBundleContext(final BundleContext bundleContext) {
57 this.bundleContext = bundleContext;
61 public void validate() {
66 public AutoCloseable createInstance() {
67 final WaitingServiceTracker<SchemaService> schemaServiceTracker =
68 WaitingServiceTracker.create(SchemaService.class, bundleContext);
69 final SchemaService schemaService = schemaServiceTracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
71 final WaitingServiceTracker<YangTextSourceProvider> sourceProviderTracker =
72 WaitingServiceTracker.create(YangTextSourceProvider.class, bundleContext);
73 final YangTextSourceProvider sourceProvider =
74 sourceProviderTracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
76 class GlobalSchemaServiceProxy implements AutoCloseable, SchemaService, YangTextSourceProvider {
79 schemaServiceTracker.close();
80 sourceProviderTracker.close();
84 public void addModule(final Module arg0) {
85 schemaService.addModule(arg0);
89 public SchemaContext getGlobalContext() {
90 return schemaService.getGlobalContext();
94 public SchemaContext getSessionContext() {
95 return schemaService.getSessionContext();
99 public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
100 final SchemaContextListener arg0) {
101 return schemaService.registerSchemaContextListener(arg0);
105 public void removeModule(final Module arg0) {
106 schemaService.removeModule(arg0);
110 public ListenableFuture<? extends YangTextSchemaSource> getSource(
111 final SourceIdentifier sourceIdentifier) {
112 return sourceProvider.getSource(sourceIdentifier);
116 return new GlobalSchemaServiceProxy();