Refine the RPC implementation registration
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / rpcs / DeviceRendererRPCImpl.java
1 /*
2  * Copyright © 2017 AT&T and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.transportpce.renderer.rpcs;
10
11 import org.opendaylight.mdsal.binding.api.RpcProviderService;
12 import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService;
13 import org.opendaylight.transportpce.renderer.provisiondevice.OtnDeviceRendererService;
14 import org.opendaylight.yangtools.concepts.Registration;
15 import org.osgi.service.component.annotations.Activate;
16 import org.osgi.service.component.annotations.Component;
17 import org.osgi.service.component.annotations.Deactivate;
18 import org.osgi.service.component.annotations.Reference;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 @Component(immediate = true)
23 public class DeviceRendererRPCImpl {
24
25     private static final Logger LOG = LoggerFactory.getLogger(DeviceRendererRPCImpl.class);
26     private Registration reg;
27
28     @Activate
29     public DeviceRendererRPCImpl(@Reference RpcProviderService rpcProviderService,
30             @Reference DeviceRendererService deviceRenderer,
31             @Reference OtnDeviceRendererService otnDeviceRendererService) {
32         this.reg = rpcProviderService.registerRpcImplementations(
33                 new ServicePathImpl(deviceRenderer),
34                 new OtnServicePathImpl(otnDeviceRendererService),
35                 new RendererRollbackImpl(deviceRenderer),
36                 new CreateOtsOmsImpl(deviceRenderer));
37         LOG.debug("RPC of DeviceRendererRPCImpl instantiated");
38     }
39
40     @Deactivate
41     public void close() {
42         this.reg.close();
43         LOG.info("DeviceRendererRPCImpl Closed");
44     }
45
46     public Registration getRegisteredRpc() {
47         return reg;
48     }
49 }