Convert OlmPowerServiceImpl into a Component
[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.mdsal.binding.api.RpcProviderService;
12 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.TransportpceOlmService;
13 import org.opendaylight.yangtools.concepts.ObjectRegistration;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 /**
18  * The Class OlmProvider.
19  */
20 public class OlmProvider {
21     private static final Logger LOG = LoggerFactory.getLogger(OlmProvider.class);
22     private final RpcProviderService rpcProviderService;
23     private final TransportpceOlmService olmPowerServiceRpc;
24     private ObjectRegistration<TransportpceOlmService> olmRPCRegistration;
25
26     /**
27      * Instantiates a new olm provider.
28      * @param olmPowerServiceRpc
29      *            implementation of TransportpceOlmService
30      * @param rpcProviderService
31      *            the rpc provider service
32      */
33     public OlmProvider(final RpcProviderService rpcProviderService, final TransportpceOlmService olmPowerServiceRpc) {
34         this.rpcProviderService = rpcProviderService;
35         this.olmPowerServiceRpc = olmPowerServiceRpc;
36     }
37
38     /**
39      * Method called when the blueprint container is created.
40      */
41     public void init() {
42         LOG.info("OlmProvider Session Initiated");
43         // Initializing Notification module
44         olmRPCRegistration = rpcProviderService.registerRpcImplementation(TransportpceOlmService.class,
45                 this.olmPowerServiceRpc);
46     }
47
48     /**
49      * Method called when the blueprint container is destroyed.
50      */
51     public void close() {
52         LOG.info("OlmProvider Closed");
53         // Clean up the RPC service registration
54         if (olmRPCRegistration != null) {
55             olmRPCRegistration.close();
56         }
57     }
58 }