3a33a43a35c9d1ed44a79967e9f380d394f85928
[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.osgi.service.component.annotations.Activate;
15 import org.osgi.service.component.annotations.Component;
16 import org.osgi.service.component.annotations.Deactivate;
17 import org.osgi.service.component.annotations.Reference;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 /**
22  * The Class OlmProvider.
23  */
24 @Component
25 public class OlmProvider {
26     private static final Logger LOG = LoggerFactory.getLogger(OlmProvider.class);
27     private ObjectRegistration<TransportpceOlmService> olmRPCRegistration;
28
29     /**
30      * Instantiates a new olm provider.
31      * @param olmPowerServiceRpc
32      *            implementation of TransportpceOlmService
33      * @param rpcProviderService
34      *            the rpc provider service
35      */
36     @Activate
37     public OlmProvider(@Reference final RpcProviderService rpcProviderService,
38             @Reference final TransportpceOlmService olmPowerServiceRpc) {
39         olmRPCRegistration = rpcProviderService.registerRpcImplementation(TransportpceOlmService.class,
40                 olmPowerServiceRpc);
41         LOG.info("OlmProvider Session Initiated");
42     }
43
44     /**
45      * Method called when the blueprint container is destroyed.
46      */
47     @Deactivate
48     public void close() {
49         LOG.info("OlmProvider Closed");
50         // Clean up the RPC service registration
51         if (olmRPCRegistration != null) {
52             olmRPCRegistration.close();
53         }
54     }
55 }