Renderer and OLM update
[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.sal.binding.api.BindingAwareBroker.RpcRegistration;
12 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
13 import org.opendaylight.transportpce.olm.service.OlmPowerService;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.olm.rev170418.OlmService;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
17
18 /**
19  * The Class OlmProvider.
20  */
21 public class OlmProvider {
22     private static final Logger LOG = LoggerFactory.getLogger(OlmProvider.class);
23     private final RpcProviderRegistry rpcProviderRegistry;
24     private final OlmPowerService olmPowerService;
25     private RpcRegistration<OlmService> olmRPCRegistration;
26
27     /**
28      * Instantiates a new olm provider.
29      * @param olmPowerService
30      *            implementation of OlmService
31      * @param rpcProviderRegistry
32      *            the rpc provider registry
33      */
34     public OlmProvider(final RpcProviderRegistry rpcProviderRegistry, final OlmPowerService olmPowerService) {
35         this.rpcProviderRegistry = rpcProviderRegistry;
36         this.olmPowerService = olmPowerService;
37     }
38
39     /**
40      * Method called when the blueprint container is created.
41      */
42     public void init() {
43         LOG.info("OlmProvider Session Initiated");
44         // Initializing Notification module
45         olmRPCRegistration = rpcProviderRegistry.addRpcImplementation(OlmService.class, new OlmPowerServiceRpcImpl(
46             this.olmPowerService));
47     }
48
49     /**
50      * Method called when the blueprint container is destroyed.
51      */
52     public void close() {
53         LOG.info("RendererProvider Closed");
54         // Clean up the RPC service registration
55         if (olmRPCRegistration != null) {
56             olmRPCRegistration.close();
57         }
58     }
59 }