6325d333d04a6384ada21eb518757833f44d8a55
[transportpce.git] / olm / src / main / java / org / opendaylight / transportpce / olm / OlmProvider.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
9 package org.opendaylight.transportpce.olm;
10
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.md.sal.binding.api.MountPointService;
13 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
14 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.OlmService;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 /**
20  * The Class OlmProvider.
21  */
22 public class OlmProvider {
23
24     /** The Constant LOG. */
25     private static final Logger LOG = LoggerFactory.getLogger(OlmProvider.class);
26
27     /** The data broker. */
28     private final DataBroker dataBroker;
29
30     /** The mount point service. */
31     private final MountPointService mountPointService;
32
33     /** The rpc provider registry. */
34     private final RpcProviderRegistry rpcProviderRegistry;
35
36     /** The get pm registration. */
37     private RpcRegistration<OlmService> olmRPCRegistration;
38
39     /**
40      * Instantiates a new olm provider.
41      *
42      * @param dataBroker
43      *            the data broker
44      * @param mountPointService
45      *            the mount point service
46      * @param rpcProviderRegistry
47      *            the rpc provider registry
48      */
49     public OlmProvider(final DataBroker dataBroker, final MountPointService mountPointService,
50         final RpcProviderRegistry rpcProviderRegistry) {
51         this.dataBroker = dataBroker;
52         this.mountPointService = mountPointService;
53         this.rpcProviderRegistry = rpcProviderRegistry;
54         if (mountPointService == null) {
55             LOG.error("Mount service is null");
56         }
57     }
58
59     /**
60      * Method called when the blueprint container is created.
61      */
62     public void init() {
63         LOG.info("OlmProvider Session Initiated");
64         // Initializing Notification module
65         olmRPCRegistration = rpcProviderRegistry.addRpcImplementation(OlmService.class, new OlmPowerSetupImpl(
66             dataBroker,mountPointService));
67     }
68
69     /**
70      * Method called when the blueprint container is destroyed.
71      */
72     public void close() {
73         LOG.info("RendererProvider Closed");
74         // Clean up the RPC service registration
75         if (olmRPCRegistration != null) {
76             olmRPCRegistration.close();
77         }
78     }
79 }