Network topology and inventory init
[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.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
11 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
12 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
13 import org.opendaylight.transportpce.renderer.rpcs.DeviceRendererRPCImpl;
14 import org.opendaylight.transportpce.renderer.rpcs.TransportPCEServicePathRPCImpl;
15 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.TransportpceServicepathService;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.RendererService;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 public class RendererProvider {
21
22     private static final Logger LOG = LoggerFactory.getLogger(RendererProvider.class);
23     private final RpcProviderRegistry rpcProviderRegistry;
24     private RpcRegistration<RendererService> deviceRendererRegistration;
25     private DeviceRendererRPCImpl deviceRendererRPCImpl;
26     private RpcRegistration<TransportpceServicepathService> tpceServiceRegistry;
27     private RendererServiceOperations rendererServiceOperations;
28
29     public RendererProvider(RpcProviderRegistry rpcProviderRegistry, DeviceRendererRPCImpl deviceRendererRPCImpl,
30                             RendererServiceOperations rendererServiceOperations) {
31         this.rpcProviderRegistry = rpcProviderRegistry;
32         this.deviceRendererRPCImpl = deviceRendererRPCImpl;
33         this.rendererServiceOperations = rendererServiceOperations;
34     }
35
36     /**
37      * Method called when the blueprint container is created.
38      */
39     public void init() {
40         LOG.info("RendererProvider Session Initiated");
41         TransportPCEServicePathRPCImpl transportPCEServicePathRPCImpl =
42             new TransportPCEServicePathRPCImpl(this.rendererServiceOperations);
43         this.deviceRendererRegistration = this.rpcProviderRegistry
44                 .addRpcImplementation(RendererService.class, this.deviceRendererRPCImpl);
45         this.tpceServiceRegistry = this.rpcProviderRegistry
46                 .addRpcImplementation(TransportpceServicepathService.class, transportPCEServicePathRPCImpl);
47     }
48
49     /**
50      * Method called when the blueprint container is destroyed.
51      */
52     public void close() {
53         LOG.info("RendererProvider Closed");
54         if (this.deviceRendererRegistration != null) {
55             this.deviceRendererRegistration.close();
56         }
57         if (this.tpceServiceRegistry != null) {
58             this.tpceServiceRegistry.close();
59         }
60     }
61
62 }