d76d56306bdc5bccc3c2ecceeefd8917adec8ae2
[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 com.google.common.collect.ImmutableClassToInstanceMap;
12 import org.opendaylight.mdsal.binding.api.RpcProviderService;
13 import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService;
14 import org.opendaylight.transportpce.renderer.provisiondevice.OtnDeviceRendererService;
15 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.CreateOtsOms;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.OtnServicePath;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.RendererRollback;
18 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePath;
19 import org.opendaylight.yangtools.concepts.Registration;
20 import org.opendaylight.yangtools.yang.binding.Rpc;
21 import org.osgi.service.component.annotations.Activate;
22 import org.osgi.service.component.annotations.Component;
23 import org.osgi.service.component.annotations.Deactivate;
24 import org.osgi.service.component.annotations.Reference;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27
28 @Component(immediate = true)
29 public class DeviceRendererRPCImpl {
30
31     private static final Logger LOG = LoggerFactory.getLogger(DeviceRendererRPCImpl.class);
32     private Registration reg;
33
34     @Activate
35     public DeviceRendererRPCImpl(@Reference RpcProviderService rpcProviderService,
36             @Reference DeviceRendererService deviceRenderer,
37             @Reference OtnDeviceRendererService otnDeviceRendererService) {
38         this.reg = rpcProviderService.registerRpcImplementations(ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
39             .put(ServicePath.class, new ServicePathImpl(deviceRenderer))
40             .put(OtnServicePath.class, new OtnServicePathImpl(otnDeviceRendererService))
41             .put(RendererRollback.class, new RendererRollbackImpl(deviceRenderer))
42             .put(CreateOtsOms.class, new CreateOtsOmsImpl(deviceRenderer))
43             .build());
44         LOG.debug("RPC of DeviceRendererRPCImpl instantiated");
45     }
46
47     @Deactivate
48     public void close() {
49         this.reg.close();
50         LOG.info("DeviceRendererRPCImpl Closed");
51     }
52
53     public Registration getRegisteredRpc() {
54         return reg;
55     }
56 }