56143f4f7a6f548d273684510a01d8fcb2890684
[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 org.opendaylight.mdsal.binding.api.RpcProviderService;
11 import org.opendaylight.transportpce.pce.service.PathComputationService;
12 import org.opendaylight.yangtools.concepts.Registration;
13 import org.osgi.service.component.annotations.Activate;
14 import org.osgi.service.component.annotations.Component;
15 import org.osgi.service.component.annotations.Deactivate;
16 import org.osgi.service.component.annotations.Reference;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 /**
21  * PceService implementation.
22  */
23 @Component(immediate = true)
24 public class PceServiceRPCImpl {
25     private static final Logger LOG = LoggerFactory.getLogger(PceServiceRPCImpl.class);
26     private Registration reg;
27
28     @Activate
29     public PceServiceRPCImpl(@Reference RpcProviderService rpcProviderService,
30             @Reference PathComputationService pathComputationService) {
31         this.reg = rpcProviderService.registerRpcImplementations(
32                 new CancelResourceReserveImpl(pathComputationService),
33                 new PathComputationRequestImpl(pathComputationService),
34                 new PathComputationRerouteRequestImpl(pathComputationService));
35         LOG.info("PceServiceRPCImpl instantiated");
36     }
37
38     @Deactivate
39     public void close() {
40         this.reg.close();
41         LOG.info("PceServiceRPCImpl Closed");
42     }
43
44     public Registration getRegisteredRpc() {
45         return reg;
46     }
47 }