Bump upstream dependencies to Ca
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / impl / PceServiceRPCImpl.java
1 /*
2  * Copyright © 2017 AT&T, Inc. 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 package org.opendaylight.transportpce.pce.impl;
9
10 import com.google.common.collect.ImmutableClassToInstanceMap;
11 import org.opendaylight.mdsal.binding.api.RpcProviderService;
12 import org.opendaylight.transportpce.pce.service.PathComputationService;
13 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserve;
14 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequest;
15 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequest;
16 import org.opendaylight.yangtools.concepts.Registration;
17 import org.opendaylight.yangtools.yang.binding.Rpc;
18 import org.osgi.service.component.annotations.Activate;
19 import org.osgi.service.component.annotations.Component;
20 import org.osgi.service.component.annotations.Deactivate;
21 import org.osgi.service.component.annotations.Reference;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25 /**
26  * PceService implementation.
27  */
28 @Component(immediate = true)
29 public class PceServiceRPCImpl {
30     private static final Logger LOG = LoggerFactory.getLogger(PceServiceRPCImpl.class);
31     private Registration reg;
32
33     @Activate
34     public PceServiceRPCImpl(@Reference RpcProviderService rpcProviderService,
35             @Reference PathComputationService pathComputationService) {
36         this.reg = rpcProviderService.registerRpcImplementations(ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
37             .put(CancelResourceReserve.class, new CancelResourceReserveImpl(pathComputationService))
38             .put(PathComputationRequest.class, new PathComputationRequestImpl(pathComputationService))
39             .put(PathComputationRerouteRequest.class, new PathComputationRerouteRequestImpl(pathComputationService))
40             .build());
41         LOG.info("PceServiceRPCImpl instantiated");
42     }
43
44     @Deactivate
45     public void close() {
46         this.reg.close();
47         LOG.info("PceServiceRPCImpl Closed");
48     }
49
50     public Registration getRegisteredRpc() {
51         return reg;
52     }
53 }