Minor checkstyle corrections
[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 java.util.HashSet;
11 import java.util.Set;
12
13 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
14 import org.opendaylight.controller.md.sal.binding.api.MountPointService;
15 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
16 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
17 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
18 import org.opendaylight.transportpce.common.mapping.PortMapping;
19 import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
20 import org.opendaylight.transportpce.renderer.rpcs.DeviceRendererRPCImpl;
21 import org.opendaylight.transportpce.renderer.rpcs.TransportPCEServicePathRPCImpl;
22 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.TransportpceServicepathService;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.RendererService;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26
27 public class RendererProvider {
28
29     private static final Logger LOG = LoggerFactory.getLogger(RendererProvider.class);
30     private final DataBroker dataBroker;
31     private final MountPointService mountPointService;
32     private final RpcProviderRegistry rpcProviderRegistry;
33     private final PortMapping portMapping;
34     private final DeviceTransactionManager deviceTransactionManager;
35     private RpcRegistration<RendererService> deviceRendererRegistration;
36     private DeviceRendererRPCImpl deviceRendererRPCImpl;
37     private RpcRegistration<TransportpceServicepathService> tpceServiceRegistry;
38     private RendererServiceOperations rendererServiceOperations;
39     private RendererNotificationsImpl rendererNotificationsImpl;
40     private final Set<String> currentMountedDevice;
41
42     public RendererProvider(RpcProviderRegistry rpcProviderRegistry, DeviceRendererRPCImpl deviceRendererRPCImpl,
43                             RendererServiceOperations rendererServiceOperations,DataBroker dataBroker,
44                             MountPointService mountPointService, PortMapping portMapping,
45                             DeviceTransactionManager deviceTransactionManager) {
46         this.rpcProviderRegistry = rpcProviderRegistry;
47         this.deviceRendererRPCImpl = deviceRendererRPCImpl;
48         this.rendererServiceOperations = rendererServiceOperations;
49         this.dataBroker = dataBroker;
50         this.mountPointService = mountPointService;
51         this.currentMountedDevice = new HashSet<>();
52         this.portMapping = portMapping;
53         this.deviceTransactionManager = deviceTransactionManager;
54     }
55
56     /**
57      * Method called when the blueprint container is created.
58      */
59     public void init() {
60         LOG.info("RendererProvider Session Initiated");
61         TransportPCEServicePathRPCImpl transportPCEServicePathRPCImpl =
62             new TransportPCEServicePathRPCImpl(this.rendererServiceOperations);
63         this.deviceRendererRegistration = this.rpcProviderRegistry
64                 .addRpcImplementation(RendererService.class, this.deviceRendererRPCImpl);
65         this.tpceServiceRegistry = this.rpcProviderRegistry
66                 .addRpcImplementation(TransportpceServicepathService.class, transportPCEServicePathRPCImpl);
67         this.rendererNotificationsImpl = new RendererNotificationsImpl(this.dataBroker, this.mountPointService,
68                 this.currentMountedDevice,this.portMapping,this.deviceTransactionManager);
69     }
70
71     /**
72      * Method called when the blueprint container is destroyed.
73      */
74     public void close() {
75         LOG.info("RendererProvider Closed");
76         if (this.deviceRendererRegistration != null) {
77             this.deviceRendererRegistration.close();
78         }
79         if (this.tpceServiceRegistry != null) {
80             this.tpceServiceRegistry.close();
81         }
82         // Clean up the RendererNotificationsImpl
83         if (this.rendererNotificationsImpl != null) {
84             this.rendererNotificationsImpl.close();
85         }
86     }
87
88 }