Manage ODU4 services over multiple OTU4
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / RendererProvider.java
index 66eee2251f66766c8f160eab9238cac59b8b8b80..3bfacdc7373f0c956c14fb29ffad2a5e408453bc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2016 Orange and others.  All rights reserved.
+ * Copyright © 2017 AT&T and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -7,24 +7,30 @@
  */
 package org.opendaylight.transportpce.renderer;
 
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
-
-
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
+import org.opendaylight.transportpce.renderer.rpcs.DeviceRendererRPCImpl;
+import org.opendaylight.transportpce.renderer.rpcs.TransportPCEServicePathRPCImpl;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.TransportpceDeviceRendererService;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.TransportpceRendererService;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class RendererProvider {
 
     private static final Logger LOG = LoggerFactory.getLogger(RendererProvider.class);
-
-    private final DataBroker dataBroker;
-
-    private final MountPointService mountPointService;
-
-    public RendererProvider(final DataBroker dataBroker, final MountPointService mountPointService) {
-        this.dataBroker = dataBroker;
-        this.mountPointService = mountPointService;
+    private final RpcProviderService rpcProviderService;
+    private DeviceRendererRPCImpl deviceRendererRPCImpl;
+    private ObjectRegistration<DeviceRendererRPCImpl> deviceRendererRegistration;
+    private ObjectRegistration<TransportpceRendererService> tpceServiceRegistry;
+    private RendererServiceOperations rendererServiceOperations;
+
+    public RendererProvider(RpcProviderService rpcProviderService, DeviceRendererRPCImpl deviceRendererRPCImpl,
+            RendererServiceOperations rendererServiceOperations) {
+        this.rpcProviderService = rpcProviderService;
+        this.deviceRendererRPCImpl = deviceRendererRPCImpl;
+        this.rendererServiceOperations = rendererServiceOperations;
     }
 
     /**
@@ -32,6 +38,12 @@ public class RendererProvider {
      */
     public void init() {
         LOG.info("RendererProvider Session Initiated");
+        TransportPCEServicePathRPCImpl transportPCEServicePathRPCImpl =
+            new TransportPCEServicePathRPCImpl(this.rendererServiceOperations);
+        this.deviceRendererRegistration = this.rpcProviderService
+                .registerRpcImplementation(TransportpceDeviceRendererService.class, deviceRendererRPCImpl);
+        this.tpceServiceRegistry = this.rpcProviderService
+                .registerRpcImplementation(TransportpceRendererService.class, transportPCEServicePathRPCImpl);
     }
 
     /**
@@ -39,5 +51,12 @@ public class RendererProvider {
      */
     public void close() {
         LOG.info("RendererProvider Closed");
+        if (this.deviceRendererRegistration != null) {
+            this.deviceRendererRegistration.close();
+        }
+        if (this.tpceServiceRegistry != null) {
+            this.tpceServiceRegistry.close();
+        }
     }
+
 }