New version of yang transportpce-renderer
[transportpce.git] / servicehandler / src / main / java / org / opendaylight / transportpce / servicehandler / impl / ServicehandlerProvider.java
index 250c5ee83abf9239d61d6bda2844d46508810d94..33c268cf5b7c5591fa7db427673f4db3e3e401dd 100644 (file)
@@ -8,16 +8,20 @@
 
 package org.opendaylight.transportpce.servicehandler.impl;
 
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-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.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.binding.api.NotificationService;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.transportpce.pce.service.PathComputationService;
+import org.opendaylight.transportpce.renderer.NetworkModelWavelengthService;
 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
 import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PceListener;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.OrgOpenroadmServiceService;
+import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev200128.TransportpcePceListener;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev201125.TransportpceRendererListener;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.OrgOpenroadmServiceService;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -32,21 +36,28 @@ public class ServicehandlerProvider {
     private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerProvider.class);
 
     private final DataBroker dataBroker;
-    private final RpcProviderRegistry rpcRegistry;
+    private final RpcProviderService rpcService;
     private final NotificationService notificationService;
-    private ListenerRegistration<PceListener> pcelistenerRegistration;
-    private RpcRegistration<OrgOpenroadmServiceService> rpcRegistration;
+    private final NetworkModelWavelengthService networkModelWavelengthService;
+    private final NotificationPublishService notificationPublishService;
+    private ListenerRegistration<TransportpcePceListener> pcelistenerRegistration;
+    private ListenerRegistration<TransportpceRendererListener> rendererlistenerRegistration;
+    private ObjectRegistration<OrgOpenroadmServiceService> rpcRegistration;
     private PathComputationService pathComputationService;
     private RendererServiceOperations rendererServiceOperations;
 
-    public ServicehandlerProvider(final DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry,
+    public ServicehandlerProvider(final DataBroker dataBroker, RpcProviderService rpcProviderService,
             NotificationService notificationService, PathComputationService pathComputationService,
-            RendererServiceOperations rendererServiceOperations) {
+            RendererServiceOperations rendererServiceOperations,
+            NetworkModelWavelengthService networkModelWavelengthService,
+            NotificationPublishService notificationPublishService) {
         this.dataBroker = dataBroker;
-        this.rpcRegistry = rpcProviderRegistry;
+        this.rpcService = rpcProviderService;
         this.notificationService = notificationService;
         this.pathComputationService = pathComputationService;
         this.rendererServiceOperations = rendererServiceOperations;
+        this.networkModelWavelengthService = networkModelWavelengthService;
+        this.notificationPublishService = notificationPublishService;
     }
 
     /**
@@ -54,11 +65,17 @@ public class ServicehandlerProvider {
      */
     public void init() {
         LOG.info("ServicehandlerProvider Session Initiated");
+        final PceListenerImpl pceListenerImpl = new PceListenerImpl(rendererServiceOperations,
+                pathComputationService, notificationPublishService, null);
+        final RendererListenerImpl rendererListenerImpl =
+                new RendererListenerImpl(pathComputationService, notificationPublishService);
+        pcelistenerRegistration = notificationService.registerNotificationListener(pceListenerImpl);
+        rendererlistenerRegistration = notificationService.registerNotificationListener(rendererListenerImpl);
         final ServicehandlerImpl servicehandler = new ServicehandlerImpl(dataBroker, pathComputationService,
-                rendererServiceOperations);
-        final PceListenerImpl pceListener = new PceListenerImpl();
-        pcelistenerRegistration = notificationService.registerNotificationListener(pceListener);
-        rpcRegistration = rpcRegistry.addRpcImplementation(OrgOpenroadmServiceService.class, servicehandler);
+                rendererServiceOperations, notificationPublishService, pceListenerImpl, rendererListenerImpl,
+                networkModelWavelengthService);
+        rpcRegistration =
+            rpcService.registerRpcImplementation(OrgOpenroadmServiceService.class, servicehandler);
     }
 
     /**
@@ -67,6 +84,7 @@ public class ServicehandlerProvider {
     public void close() {
         LOG.info("ServicehandlerProvider Closed");
         pcelistenerRegistration.close();
+        rendererlistenerRegistration.close();
         rpcRegistration.close();
     }