X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyang%2Fmd%2Fsal%2Fdom%2Fimpl%2FSchemaServiceImplSingletonModule.java;fp=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyang%2Fmd%2Fsal%2Fdom%2Fimpl%2FSchemaServiceImplSingletonModule.java;h=8152cbd6b1914bd654e9b4d12abc45d4467ddadb;hp=d61d709600b0761c2f2659e683574c98fed55a3d;hb=ab7bfb1d8a4f5c0fb800074c9a8f12caeb35925c;hpb=2d9dc00aaaa1a059dcca7861484698a95de0644e diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/SchemaServiceImplSingletonModule.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/SchemaServiceImplSingletonModule.java index d61d709600..8152cbd6b1 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/SchemaServiceImplSingletonModule.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/SchemaServiceImplSingletonModule.java @@ -1,34 +1,43 @@ /** -* Generated file + * Generated file -* Generated from: yang module name: opendaylight-sal-dom-broker-impl yang module local name: schema-service-singleton -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Wed Nov 20 17:01:31 CET 2013 -* -* Do not modify this file unless it is present under src/main directory -*/ + * Generated from: yang module name: opendaylight-sal-dom-broker-impl yang module local name: schema-service-singleton + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 20 17:01:31 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ package org.opendaylight.controller.config.yang.md.sal.dom.impl; -import org.opendaylight.controller.sal.dom.broker.SchemaServiceImpl; -import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; +import org.opendaylight.controller.sal.core.api.model.SchemaService; +import org.opendaylight.controller.sal.dom.broker.GlobalBundleScanningSchemaServiceImpl; +import org.opendaylight.yangtools.concepts.Delegator; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener; import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; /** * */ -public final class SchemaServiceImplSingletonModule extends org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractSchemaServiceImplSingletonModule -{ +public final class SchemaServiceImplSingletonModule extends + org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractSchemaServiceImplSingletonModule { BundleContext bundleContext; - - public SchemaServiceImplSingletonModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + + public SchemaServiceImplSingletonModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { super(identifier, dependencyResolver); } - public SchemaServiceImplSingletonModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, SchemaServiceImplSingletonModule oldModule, java.lang.AutoCloseable oldInstance) { + public SchemaServiceImplSingletonModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + SchemaServiceImplSingletonModule oldModule, java.lang.AutoCloseable oldInstance) { super(identifier, dependencyResolver, oldModule, oldInstance); } - + @Override public boolean canReuseInstance(AbstractSchemaServiceImplSingletonModule oldModule) { return true; @@ -43,15 +52,69 @@ public final class SchemaServiceImplSingletonModule extends org.opendaylight.con } @Override - public void validate(){ + public void validate() { super.validate(); } @Override public java.lang.AutoCloseable createInstance() { - SchemaServiceImpl newInstance = new SchemaServiceImpl(); + ServiceReference ref = getBundleContext().getServiceReference(SchemaService.class); + if (ref != null) { + return new GlobalSchemaServiceProxy(getBundleContext(), ref); + } + + GlobalBundleScanningSchemaServiceImpl newInstance = new GlobalBundleScanningSchemaServiceImpl(); newInstance.setContext(getBundleContext()); newInstance.start(); return newInstance; } + + public class GlobalSchemaServiceProxy implements AutoCloseable, SchemaService, Delegator { + + private BundleContext bundleContext; + private ServiceReference reference; + private SchemaService delegate; + + public GlobalSchemaServiceProxy(BundleContext bundleContext, ServiceReference ref) { + this.bundleContext = bundleContext; + this.reference = ref; + this.delegate = bundleContext.getService(reference); + } + + @Override + public void close() throws Exception { + if (delegate != null) { + delegate = null; + bundleContext.ungetService(reference); + reference = null; + bundleContext = null; + } + } + + public void addModule(Module arg0) { + delegate.addModule(arg0); + } + + public SchemaContext getGlobalContext() { + return delegate.getGlobalContext(); + } + + public SchemaContext getSessionContext() { + return delegate.getSessionContext(); + } + + public ListenerRegistration registerSchemaServiceListener(SchemaServiceListener arg0) { + return delegate.registerSchemaServiceListener(arg0); + } + + public void removeModule(Module arg0) { + delegate.removeModule(arg0); + } + + @Override + public SchemaService getDelegate() { + return delegate; + } + + } }