X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyang%2Fmd%2Fsal%2Fdom%2Fimpl%2FSchemaServiceImplSingletonModule.java;h=fbc418dc2aec0203d4f52ad6b7ace8cc083ca019;hb=7325ba9a87ead9d9070b1ba7018ca20d60da987c;hp=93284c98e1032f0030fff3c21d2c6c3dfc2ba1f2;hpb=21ac8568d134427df8b1539a0648377cf74d70d1;p=controller.git 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 93284c98e1..fbc418dc2a 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 @@ -15,33 +15,29 @@ 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; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** -* -*/ public final class SchemaServiceImplSingletonModule extends - org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractSchemaServiceImplSingletonModule { +org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractSchemaServiceImplSingletonModule { private static final Logger LOG = LoggerFactory.getLogger(SchemaServiceImplSingletonModule.class); BundleContext bundleContext; - public SchemaServiceImplSingletonModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, - org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + public SchemaServiceImplSingletonModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, + final 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(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, + final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + final SchemaServiceImplSingletonModule oldModule, final java.lang.AutoCloseable oldInstance) { super(identifier, dependencyResolver, oldModule, oldInstance); } @Override - public boolean canReuseInstance(AbstractSchemaServiceImplSingletonModule oldModule) { + public boolean canReuseInstance(final AbstractSchemaServiceImplSingletonModule oldModule) { return true; } @@ -49,7 +45,7 @@ public final class SchemaServiceImplSingletonModule extends return bundleContext; } - public void setBundleContext(BundleContext bundleContext) { + public void setBundleContext(final BundleContext bundleContext) { this.bundleContext = bundleContext; } @@ -60,49 +56,26 @@ public final class SchemaServiceImplSingletonModule extends @Override public java.lang.AutoCloseable createInstance() { - 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; + return GlobalBundleScanningSchemaServiceImpl.getInstance(); } 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); + public GlobalSchemaServiceProxy() { + this.delegate = GlobalBundleScanningSchemaServiceImpl.getInstance(); } @Override public void close() throws Exception { if (delegate != null) { delegate = null; - - try { - bundleContext.ungetService(reference); - } catch (IllegalStateException e) { - // Indicates the service was already unregistered which can happen normally - // on shutdown. - LOG.debug( "Error unregistering service", e ); - } - - reference = null; - bundleContext = null; } } @Override - public void addModule(Module arg0) { + public void addModule(final Module arg0) { delegate.addModule(arg0); } @@ -117,12 +90,12 @@ public final class SchemaServiceImplSingletonModule extends } @Override - public ListenerRegistration registerSchemaServiceListener(SchemaServiceListener arg0) { + public ListenerRegistration registerSchemaServiceListener(final SchemaServiceListener arg0) { return delegate.registerSchemaServiceListener(arg0); } @Override - public void removeModule(Module arg0) { + public void removeModule(final Module arg0) { delegate.removeModule(arg0); }