Search in sources :

Example 1 with SchemaService

use of org.opendaylight.controller.sal.core.api.model.SchemaService 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)

Example 2 with SchemaService

use of org.opendaylight.controller.sal.core.api.model.SchemaService in project controller by opendaylight.

the class DomBrokerImplModule method createInstance.

@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public AutoCloseable createInstance() {
    // The services are provided via blueprint so retrieve then from the OSGi service registry for
    // backwards compatibility.
    final List<AutoCloseable> closeables = new ArrayList<>();
    DOMNotificationService domNotificationService = newTracker(DOMNotificationService.class, closeables).waitForService(WaitingServiceTracker.FIVE_MINUTES);
    DOMNotificationPublishService domNotificationPublishService = newTracker(DOMNotificationPublishService.class, closeables).waitForService(WaitingServiceTracker.FIVE_MINUTES);
    DOMRpcService domRpcService = newTracker(DOMRpcService.class, closeables).waitForService(WaitingServiceTracker.FIVE_MINUTES);
    DOMRpcProviderService domRpcProvider = newTracker(DOMRpcProviderService.class, closeables).waitForService(WaitingServiceTracker.FIVE_MINUTES);
    DOMMountPointService mountService = newTracker(DOMMountPointService.class, closeables).waitForService(WaitingServiceTracker.FIVE_MINUTES);
    SchemaService globalSchemaService = newTracker(SchemaService.class, closeables).waitForService(WaitingServiceTracker.FIVE_MINUTES);
    final DOMDataBroker dataBroker = getAsyncDataBrokerDependency();
    final ClassToInstanceMap<BrokerService> services = MutableClassToInstanceMap.create();
    services.putInstance(DOMNotificationService.class, domNotificationService);
    services.putInstance(DOMNotificationPublishService.class, domNotificationPublishService);
    final SchemaService schemaService = getSchemaServiceImpl(globalSchemaService);
    services.putInstance(SchemaService.class, schemaService);
    services.putInstance(DOMDataBroker.class, dataBroker);
    services.putInstance(DOMRpcService.class, domRpcService);
    services.putInstance(DOMRpcProviderService.class, domRpcProvider);
    services.putInstance(DOMMountPointService.class, mountService);
    BrokerImpl broker = new BrokerImpl(domRpcService, domRpcProvider, services);
    broker.setDeactivator(() -> {
        for (AutoCloseable ac : closeables) {
            try {
                ac.close();
            } catch (Exception e) {
                LOG.warn("Exception while closing {}", ac, e);
            }
        }
    });
    return broker;
}
Also used : DOMRpcService(org.opendaylight.controller.md.sal.dom.api.DOMRpcService) ArrayList(java.util.ArrayList) DOMMountPointService(org.opendaylight.controller.md.sal.dom.api.DOMMountPointService) DOMRpcProviderService(org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService) DOMNotificationService(org.opendaylight.controller.md.sal.dom.api.DOMNotificationService) BrokerImpl(org.opendaylight.controller.sal.dom.broker.BrokerImpl) SchemaService(org.opendaylight.controller.sal.core.api.model.SchemaService) DOMNotificationPublishService(org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService) DOMDataBroker(org.opendaylight.controller.md.sal.dom.api.DOMDataBroker) BrokerService(org.opendaylight.controller.sal.core.api.BrokerService)

Aggregations

SchemaService (org.opendaylight.controller.sal.core.api.model.SchemaService)2 ArrayList (java.util.ArrayList)1 DOMDataBroker (org.opendaylight.controller.md.sal.dom.api.DOMDataBroker)1 DOMMountPointService (org.opendaylight.controller.md.sal.dom.api.DOMMountPointService)1 DOMNotificationPublishService (org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService)1 DOMNotificationService (org.opendaylight.controller.md.sal.dom.api.DOMNotificationService)1 DOMRpcProviderService (org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService)1 DOMRpcService (org.opendaylight.controller.md.sal.dom.api.DOMRpcService)1 BrokerService (org.opendaylight.controller.sal.core.api.BrokerService)1 YangTextSourceProvider (org.opendaylight.controller.sal.core.api.model.YangTextSourceProvider)1 BrokerImpl (org.opendaylight.controller.sal.dom.broker.BrokerImpl)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