Remove renderer-blueprint
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / RendererProvider.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 package org.opendaylight.transportpce.renderer;
9
10 import org.opendaylight.mdsal.binding.api.RpcProviderService;
11 import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService;
12 import org.opendaylight.transportpce.renderer.provisiondevice.OtnDeviceRendererService;
13 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
14 import org.opendaylight.transportpce.renderer.rpcs.DeviceRendererRPCImpl;
15 import org.opendaylight.transportpce.renderer.rpcs.TransportPCEServicePathRPCImpl;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.TransportpceDeviceRendererService;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.TransportpceRendererService;
18 import org.opendaylight.yangtools.concepts.ObjectRegistration;
19 import org.osgi.service.component.annotations.Activate;
20 import org.osgi.service.component.annotations.Component;
21 import org.osgi.service.component.annotations.Deactivate;
22 import org.osgi.service.component.annotations.Reference;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26 @Component
27 public class RendererProvider {
28
29     private static final Logger LOG = LoggerFactory.getLogger(RendererProvider.class);
30     private final RpcProviderService rpcProviderService;
31     private DeviceRendererRPCImpl deviceRendererRPCImpl;
32     private TransportPCEServicePathRPCImpl transportPCEServicePathRPCImpl;
33     private ObjectRegistration<DeviceRendererRPCImpl> deviceRendererRegistration;
34     private ObjectRegistration<TransportpceRendererService> tpceServiceRegistry;
35
36     @Activate
37     public RendererProvider(@Reference RpcProviderService rpcProviderService,
38             @Reference DeviceRendererService deviceRenderer,
39             @Reference OtnDeviceRendererService otnDeviceRendererService,
40             @Reference RendererServiceOperations rendererServiceOperations) {
41         this.rpcProviderService = rpcProviderService;
42         this.deviceRendererRPCImpl = new DeviceRendererRPCImpl(deviceRenderer, otnDeviceRendererService);
43         this.transportPCEServicePathRPCImpl = new TransportPCEServicePathRPCImpl(rendererServiceOperations);
44         LOG.info("RendererProvider Session Initiated");
45         this.deviceRendererRegistration = this.rpcProviderService
46                 .registerRpcImplementation(TransportpceDeviceRendererService.class, deviceRendererRPCImpl);
47         this.tpceServiceRegistry = this.rpcProviderService
48                 .registerRpcImplementation(TransportpceRendererService.class, transportPCEServicePathRPCImpl);
49     }
50
51     /**
52      * Method called when the blueprint container is destroyed.
53      */
54     @Deactivate
55     public void close() {
56         LOG.info("RendererProvider Closed");
57         if (this.deviceRendererRegistration != null) {
58             this.deviceRendererRegistration.close();
59         }
60         if (this.tpceServiceRegistry != null) {
61             this.tpceServiceRegistry.close();
62         }
63     }
64 }