X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=servicehandler%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fservicehandler%2Fimpl%2FServicehandlerProvider.java;h=c30e7aba14dbbfd25578c976a52e37a75a49819e;hb=27070ce7114dcdb1da7203c54724fa3fe59e7cc3;hp=29e838d16d1047921735fc94e1e7f1c50d94d967;hpb=96a25ab4d2588960ceadf60e3d97f849a8d62cbe;p=transportpce.git diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProvider.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProvider.java index 29e838d16..c30e7aba1 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProvider.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProvider.java @@ -8,15 +8,25 @@ package org.opendaylight.transportpce.servicehandler.impl; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.NotificationService; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServicehandlerService; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.StubpceListener; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererListener; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationService; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkmodel.rev201116.TransportpceNetworkmodelListener; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.TransportpcePceListener; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.TransportpceRendererListener; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.OrgOpenroadmServiceService; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceList; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.list.Services; import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,49 +36,49 @@ import org.slf4j.LoggerFactory; * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange * */ +@Component public class ServicehandlerProvider { private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerProvider.class); + private static final InstanceIdentifier SERVICE = InstanceIdentifier.builder(ServiceList.class) + .child(Services.class).build(); - private final DataBroker dataBroker; - private final RpcProviderRegistry rpcRegistry; - private final NotificationService notificationService; - private final NotificationPublishService notificationPublishService; + private ListenerRegistration pcelistenerRegistration; + private ListenerRegistration> serviceDataTreeChangeListenerRegistration; + private ListenerRegistration rendererlistenerRegistration; + private ListenerRegistration networkmodellistenerRegistration; + private ServiceDataStoreOperations serviceDataStoreOperations; - //private ListenerRegistration ServicehandlerlistenerRegistration; - /* Listener register for StubPce Notification. */ - private ListenerRegistration stubPcelistenerRegistration; - /* Listener register for StubRender Notification. */ - private ListenerRegistration stubRendererlistenerRegistration; - private RpcRegistration rpcRegistration; - - - public ServicehandlerProvider(final DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry, - NotificationService notificationService, NotificationPublishService notificationPublishService) { - this.dataBroker = dataBroker; - this.rpcRegistry = rpcProviderRegistry; - this.notificationService = notificationService; - this.notificationPublishService = notificationPublishService; - } - - /** - * Method called when the blueprint container is created. - */ - public void init() { + @Activate + public ServicehandlerProvider(@Reference final DataBroker dataBroker, + @Reference NotificationService notificationService, + @Reference ServiceDataStoreOperations serviceDataStoreOperations, + @Reference TransportpcePceListener pceListenerImpl, + @Reference TransportpceRendererListener rendererListenerImpl, + @Reference TransportpceNetworkmodelListener networkModelListenerImpl, + @Reference NotificationPublishService notificationPublishService, + @Reference OrgOpenroadmServiceService servicehandler, + @Reference DataTreeChangeListener serviceListener) { + this.serviceDataStoreOperations = serviceDataStoreOperations; + this.serviceDataStoreOperations.initialize(); + pcelistenerRegistration = notificationService.registerNotificationListener(pceListenerImpl); + rendererlistenerRegistration = notificationService.registerNotificationListener(rendererListenerImpl); + networkmodellistenerRegistration = notificationService.registerNotificationListener(networkModelListenerImpl); + serviceDataTreeChangeListenerRegistration = dataBroker.registerDataTreeChangeListener( + DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, SERVICE), serviceListener); LOG.info("ServicehandlerProvider Session Initiated"); - final ServicehandlerImpl consumer = new ServicehandlerImpl(dataBroker, rpcRegistry, notificationPublishService); - stubPcelistenerRegistration = notificationService.registerNotificationListener(consumer); - stubRendererlistenerRegistration = notificationService.registerNotificationListener(consumer); - rpcRegistration = rpcRegistry.addRpcImplementation(ServicehandlerService.class, consumer); + LOG.info("Transportpce controller started"); } /** * Method called when the blueprint container is destroyed. */ + @Deactivate public void close() { LOG.info("ServicehandlerProvider Closed"); - stubPcelistenerRegistration.close(); - stubRendererlistenerRegistration.close(); - rpcRegistration.close(); + pcelistenerRegistration.close(); + serviceDataTreeChangeListenerRegistration.close(); + rendererlistenerRegistration.close(); + networkmodellistenerRegistration.close(); } -} +} \ No newline at end of file