*/
package org.opendaylight.controller.config.yang.md.sal.dom.impl;
+import com.google.common.util.concurrent.CheckedFuture;
+import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
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.controller.sal.core.api.model.YangTextSourceProvider;
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.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
+import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
public final class SchemaServiceImplSingletonModule extends
org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractSchemaServiceImplSingletonModule {
}
@Override
- public java.lang.AutoCloseable createInstance() {
- return GlobalBundleScanningSchemaServiceImpl.getInstance();
- }
-
- public class GlobalSchemaServiceProxy implements AutoCloseable, SchemaService, Delegator<SchemaService> {
-
- private SchemaService delegate;
-
- public GlobalSchemaServiceProxy() {
- this.delegate = GlobalBundleScanningSchemaServiceImpl.getInstance();
- }
-
- @Override
- public void close() throws Exception {
- if (delegate != null) {
- delegate = null;
+ public AutoCloseable createInstance() {
+ final WaitingServiceTracker<SchemaService> schemaServiceTracker =
+ WaitingServiceTracker.create(SchemaService.class, bundleContext);
+ final SchemaService schemaService = schemaServiceTracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+
+ final WaitingServiceTracker<YangTextSourceProvider> sourceProviderTracker =
+ WaitingServiceTracker.create(YangTextSourceProvider.class, bundleContext);
+ final YangTextSourceProvider sourceProvider = sourceProviderTracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+
+ class GlobalSchemaServiceProxy implements AutoCloseable, SchemaService, YangTextSourceProvider {
+ @Override
+ public void close() {
+ schemaServiceTracker.close();
+ sourceProviderTracker.close();
}
- }
- @Override
- public void addModule(final Module arg0) {
- delegate.addModule(arg0);
- }
+ @Override
+ public void addModule(final Module arg0) {
+ schemaService.addModule(arg0);
+ }
- @Override
- public SchemaContext getGlobalContext() {
- return delegate.getGlobalContext();
- }
+ @Override
+ public SchemaContext getGlobalContext() {
+ return schemaService.getGlobalContext();
+ }
- @Override
- public SchemaContext getSessionContext() {
- return delegate.getSessionContext();
- }
+ @Override
+ public SchemaContext getSessionContext() {
+ return schemaService.getSessionContext();
+ }
- @Override
- public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(final SchemaContextListener arg0) {
- return delegate.registerSchemaContextListener(arg0);
- }
+ @Override
+ public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(final SchemaContextListener arg0) {
+ return schemaService.registerSchemaContextListener(arg0);
+ }
- @Override
- public void removeModule(final Module arg0) {
- delegate.removeModule(arg0);
- }
+ @Override
+ public void removeModule(final Module arg0) {
+ schemaService.removeModule(arg0);
+ }
- @Override
- public SchemaService getDelegate() {
- return delegate;
+ @Override
+ public CheckedFuture<? extends YangTextSchemaSource, SchemaSourceException> getSource(
+ SourceIdentifier sourceIdentifier) {
+ return sourceProvider.getSource(sourceIdentifier);
+ }
}
+ return new GlobalSchemaServiceProxy();
}
}