2 * Copyright © 2017 AT&T and others. All rights reserved.
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
8 package org.opendaylight.transportpce.renderer;
10 import java.util.HashSet;
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;
27 public class RendererProvider {
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;
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;
57 * Method called when the blueprint container is created.
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);
72 * Method called when the blueprint container is destroyed.
75 LOG.info("RendererProvider Closed");
76 if (this.deviceRendererRegistration != null) {
77 this.deviceRendererRegistration.close();
79 if (this.tpceServiceRegistry != null) {
80 this.tpceServiceRegistry.close();
82 // Clean up the RendererNotificationsImpl
83 if (this.rendererNotificationsImpl != null) {
84 this.rendererNotificationsImpl.close();