2 * Copyright © 2017 AT&T and others. All rights reserved.
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
9 package org.opendaylight.transportpce.olm;
11 import com.google.common.collect.ImmutableClassToInstanceMap;
12 import org.opendaylight.mdsal.binding.api.RpcProviderService;
13 import org.opendaylight.transportpce.olm.rpc.impl.CalculateSpanlossBaseImpl;
14 import org.opendaylight.transportpce.olm.rpc.impl.CalculateSpanlossCurrentImpl;
15 import org.opendaylight.transportpce.olm.rpc.impl.GetPmImpl;
16 import org.opendaylight.transportpce.olm.rpc.impl.ServicePowerResetImpl;
17 import org.opendaylight.transportpce.olm.rpc.impl.ServicePowerSetupImpl;
18 import org.opendaylight.transportpce.olm.rpc.impl.ServicePowerTurndownImpl;
19 import org.opendaylight.transportpce.olm.service.OlmPowerService;
20 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossBase;
21 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossCurrent;
22 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPm;
23 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerReset;
24 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerSetup;
25 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerTurndown;
26 import org.opendaylight.yangtools.concepts.Registration;
27 import org.opendaylight.yangtools.yang.binding.Rpc;
28 import org.osgi.service.component.annotations.Activate;
29 import org.osgi.service.component.annotations.Component;
30 import org.osgi.service.component.annotations.Deactivate;
31 import org.osgi.service.component.annotations.Reference;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
36 * The Class OlmPowerServiceRpcImpl.
39 public class OlmPowerServiceRpcImpl {
40 private static final Logger LOG = LoggerFactory.getLogger(OlmPowerServiceRpcImpl.class);
41 private Registration rpcRegistration;
44 public OlmPowerServiceRpcImpl(@Reference OlmPowerService olmPowerService,
45 @Reference RpcProviderService rpcProviderService) {
46 this.rpcRegistration = rpcProviderService.registerRpcImplementations(
47 ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
48 .put(GetPm.class, new GetPmImpl(olmPowerService))
49 .put(ServicePowerSetup.class, new ServicePowerSetupImpl(olmPowerService))
50 .put(ServicePowerTurndown.class, new ServicePowerTurndownImpl(olmPowerService))
51 .put(CalculateSpanlossBase.class, new CalculateSpanlossBaseImpl(olmPowerService))
52 .put(CalculateSpanlossCurrent.class, new CalculateSpanlossCurrentImpl(olmPowerService))
53 .put(ServicePowerReset.class, new ServicePowerResetImpl(olmPowerService))
55 LOG.info("OlmPowerServiceRpcImpl instantiated");
60 this.rpcRegistration.close();
61 LOG.info("OlmPowerServiceRpcImpl Closed");
64 public Registration getRegisteredRpc() {
65 return rpcRegistration;