Bump upstream dependencies to Ca
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / impl / PceServiceRPCImpl.java
old mode 100755 (executable)
new mode 100644 (file)
index f078bdc..49f8e71
@@ -7,49 +7,47 @@
  */
 package org.opendaylight.transportpce.pce.impl;
 
-import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.collect.ImmutableClassToInstanceMap;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.transportpce.pce.service.PathComputationService;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.CancelResourceReserveInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.CancelResourceReserveOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestInput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.PathComputationRequestOutput;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.TransportpcePceService;
-/*
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev170426.service.path.rpc.result.PathDescriptionBuilder;
-///// check well PathDescriptionBuilder import
-//---------------------------------------------
-*/
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserve;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequest;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequest;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.Rpc;
+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;
 
 /**
  * PceService implementation.
  */
-public class PceServiceRPCImpl implements TransportpcePceService {
-
+@Component(immediate = true)
+public class PceServiceRPCImpl {
     private static final Logger LOG = LoggerFactory.getLogger(PceServiceRPCImpl.class);
-
-    private final PathComputationService pathComputationService;
-
-    public PceServiceRPCImpl(PathComputationService pathComputationService) {
-        this.pathComputationService = pathComputationService;
+    private Registration reg;
+
+    @Activate
+    public PceServiceRPCImpl(@Reference RpcProviderService rpcProviderService,
+            @Reference PathComputationService pathComputationService) {
+        this.reg = rpcProviderService.registerRpcImplementations(ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
+            .put(CancelResourceReserve.class, new CancelResourceReserveImpl(pathComputationService))
+            .put(PathComputationRequest.class, new PathComputationRequestImpl(pathComputationService))
+            .put(PathComputationRerouteRequest.class, new PathComputationRerouteRequestImpl(pathComputationService))
+            .build());
+        LOG.info("PceServiceRPCImpl instantiated");
     }
 
-    @Override
-    public ListenableFuture<RpcResult<CancelResourceReserveOutput>>
-            cancelResourceReserve(CancelResourceReserveInput input) {
-        LOG.info("RPC cancelResourceReserve request received");
-        return RpcResultBuilder.success(this.pathComputationService.cancelResourceReserve(input)).buildFuture();
+    @Deactivate
+    public void close() {
+        this.reg.close();
+        LOG.info("PceServiceRPCImpl Closed");
     }
 
-
-    @Override
-    public ListenableFuture<RpcResult<PathComputationRequestOutput>>
-            pathComputationRequest(PathComputationRequestInput input) {
-        LOG.info("RPC path computation request received");
-        return RpcResultBuilder.success(this.pathComputationService.pathComputationRequest(input)).buildFuture();
+    public Registration getRegisteredRpc() {
+        return reg;
     }
-
 }