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
9 package org.opendaylight.transportpce.renderer;
11 import java.util.HashSet;
14 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
15 import org.opendaylight.controller.md.sal.binding.api.MountPointService;
16 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
17 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
18 import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRenderer;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.renderer.rev170228.RendererService;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 public class RendererProvider {
25 private static final Logger LOG = LoggerFactory.getLogger(RendererProvider.class);
26 private final DataBroker dataBroker;
27 private final MountPointService mountPointService;
28 private final RpcProviderRegistry rpcProviderRegistry;
29 private RendererNotificationsImpl rendererNotificationImpl;
30 private RpcRegistration<RendererService> deviceRendererRegistration;
31 private final Set<String> currentMountedDevice;
33 public RendererProvider(final DataBroker dataBroker, final MountPointService mountPointService,
34 final RpcProviderRegistry rpcProviderRegistry) {
35 this.dataBroker = dataBroker;
36 this.mountPointService = mountPointService;
37 this.rpcProviderRegistry = rpcProviderRegistry;
38 this.currentMountedDevice = new HashSet<>();
39 if (mountPointService == null) {
40 LOG.error("Mount service is null");
45 * Method called when the blueprint container is created.
48 LOG.info("RendererProvider Session Initiated");
49 // Initializing Notification module
50 rendererNotificationImpl = new RendererNotificationsImpl(dataBroker, mountPointService,
51 currentMountedDevice);
52 //Register REST API RPC implementation for Renderer Service
53 deviceRendererRegistration = rpcProviderRegistry.addRpcImplementation(RendererService.class, new DeviceRenderer(
54 dataBroker, mountPointService, currentMountedDevice));
58 * Method called when the blueprint container is destroyed.
61 LOG.info("RendererProvider Closed");
62 // Clean up the RPC service registration
63 if (deviceRendererRegistration != null) {
64 deviceRendererRegistration.close();
66 // Clean up the RendererNotificationsImpl
67 if (rendererNotificationImpl != null) {
68 rendererNotificationImpl.close();