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 org.opendaylight.controller.sal.core.api.model.SchemaService;
11 import org.opendaylight.controller.sal.dom.broker.GlobalBundleScanningSchemaServiceImpl;
12 import org.opendaylight.yangtools.concepts.Delegator;
13 import org.opendaylight.yangtools.concepts.ListenerRegistration;
14 import org.opendaylight.yangtools.yang.model.api.Module;
15 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
16 import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener;
17 import org.osgi.framework.BundleContext;
18 import org.osgi.framework.ServiceReference;
23 public final class SchemaServiceImplSingletonModule extends
24 org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractSchemaServiceImplSingletonModule {
26 BundleContext bundleContext;
28 public SchemaServiceImplSingletonModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
29 org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
30 super(identifier, dependencyResolver);
33 public SchemaServiceImplSingletonModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
34 org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
35 SchemaServiceImplSingletonModule oldModule, java.lang.AutoCloseable oldInstance) {
36 super(identifier, dependencyResolver, oldModule, oldInstance);
40 public boolean canReuseInstance(AbstractSchemaServiceImplSingletonModule oldModule) {
44 public BundleContext getBundleContext() {
48 public void setBundleContext(BundleContext bundleContext) {
49 this.bundleContext = bundleContext;
53 public void validate() {
58 public java.lang.AutoCloseable createInstance() {
59 ServiceReference<SchemaService> ref = getBundleContext().getServiceReference(SchemaService.class);
61 return new GlobalSchemaServiceProxy(getBundleContext(), ref);
64 GlobalBundleScanningSchemaServiceImpl newInstance = new GlobalBundleScanningSchemaServiceImpl();
65 newInstance.setContext(getBundleContext());
70 public class GlobalSchemaServiceProxy implements AutoCloseable, SchemaService, Delegator<SchemaService> {
72 private BundleContext bundleContext;
73 private ServiceReference<SchemaService> reference;
74 private SchemaService delegate;
76 public GlobalSchemaServiceProxy(BundleContext bundleContext, ServiceReference<SchemaService> ref) {
77 this.bundleContext = bundleContext;
79 this.delegate = bundleContext.getService(reference);
83 public void close() throws Exception {
84 if (delegate != null) {
86 bundleContext.ungetService(reference);
92 public void addModule(Module arg0) {
93 delegate.addModule(arg0);
96 public SchemaContext getGlobalContext() {
97 return delegate.getGlobalContext();
100 public SchemaContext getSessionContext() {
101 return delegate.getSessionContext();
104 public ListenerRegistration<SchemaServiceListener> registerSchemaServiceListener(SchemaServiceListener arg0) {
105 return delegate.registerSchemaServiceListener(arg0);
108 public void removeModule(Module arg0) {
109 delegate.removeModule(arg0);
113 public SchemaService getDelegate() {