Search in sources :

Example 1 with SourceIdentifier

use of org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier in project controller by opendaylight.

the class SchemaServiceImplSingletonModule method createInstance.

@Override
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) {
            schemaService.addModule(arg0);
        }

        @Override
        public SchemaContext getGlobalContext() {
            return schemaService.getGlobalContext();
        }

        @Override
        public SchemaContext getSessionContext() {
            return schemaService.getSessionContext();
        }

        @Override
        public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(final SchemaContextListener arg0) {
            return schemaService.registerSchemaContextListener(arg0);
        }

        @Override
        public void removeModule(final Module arg0) {
            schemaService.removeModule(arg0);
        }

        @Override
        public ListenableFuture<? extends YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier) {
            return sourceProvider.getSource(sourceIdentifier);
        }
    }
    return new GlobalSchemaServiceProxy();
}
Also used : YangTextSourceProvider(org.opendaylight.controller.sal.core.api.model.YangTextSourceProvider) SchemaService(org.opendaylight.controller.sal.core.api.model.SchemaService) SourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier) Module(org.opendaylight.yangtools.yang.model.api.Module) SchemaContextListener(org.opendaylight.yangtools.yang.model.api.SchemaContextListener)

Aggregations

SchemaService (org.opendaylight.controller.sal.core.api.model.SchemaService)1 YangTextSourceProvider (org.opendaylight.controller.sal.core.api.model.YangTextSourceProvider)1 Module (org.opendaylight.yangtools.yang.model.api.Module)1 SchemaContextListener (org.opendaylight.yangtools.yang.model.api.SchemaContextListener)1 SourceIdentifier (org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier)1