Refine the RPC implementation registration
[transportpce.git] / olm / src / main / java / org / opendaylight / transportpce / olm / OlmPowerServiceRpcImpl.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.transportpce.olm.rpc.impl.CalculateSpanlossBaseImpl;
13 import org.opendaylight.transportpce.olm.rpc.impl.CalculateSpanlossCurrentImpl;
14 import org.opendaylight.transportpce.olm.rpc.impl.GetPmImpl;
15 import org.opendaylight.transportpce.olm.rpc.impl.ServicePowerResetImpl;
16 import org.opendaylight.transportpce.olm.rpc.impl.ServicePowerSetupImpl;
17 import org.opendaylight.transportpce.olm.rpc.impl.ServicePowerTurndownImpl;
18 import org.opendaylight.transportpce.olm.service.OlmPowerService;
19 import org.opendaylight.yangtools.concepts.Registration;
20 import org.osgi.service.component.annotations.Activate;
21 import org.osgi.service.component.annotations.Component;
22 import org.osgi.service.component.annotations.Deactivate;
23 import org.osgi.service.component.annotations.Reference;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26
27 /**
28  * The Class OlmPowerServiceRpcImpl.
29  */
30 @Component
31 public class OlmPowerServiceRpcImpl {
32     private static final Logger LOG = LoggerFactory.getLogger(OlmPowerServiceRpcImpl.class);
33     private Registration rpcRegistration;
34
35     @Activate
36     public OlmPowerServiceRpcImpl(@Reference OlmPowerService olmPowerService,
37             @Reference RpcProviderService rpcProviderService) {
38         this.rpcRegistration = rpcProviderService.registerRpcImplementations(
39             new GetPmImpl(olmPowerService),
40             new ServicePowerSetupImpl(olmPowerService),
41             new ServicePowerTurndownImpl(olmPowerService),
42             new CalculateSpanlossBaseImpl(olmPowerService),
43             new CalculateSpanlossCurrentImpl(olmPowerService),
44             new ServicePowerResetImpl(olmPowerService));
45         LOG.info("OlmPowerServiceRpcImpl instantiated");
46     }
47
48     @Deactivate
49     public void close() {
50         this.rpcRegistration.close();
51         LOG.info("OlmPowerServiceRpcImpl Closed");
52     }
53
54     public Registration getRegisteredRpc() {
55         return rpcRegistration;
56     }
57 }