5a89fd77a2141cee597907a4af499846d8ad5009
[ccsdk/apps.git] / sdnr / wireless-transport / code-Carbon-SR1 / apps / route / impl / src / main / java / com / highstreet / technologies / odl / app / impl / RouteProvider.java
1 /*
2  * Copyright © 2017 ZTE 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 com.highstreet.technologies.odl.app.impl;
9
10 import com.highstreet.technologies.odl.app.impl.tools.DataBrokerHolder;
11 import com.highstreet.technologies.odl.app.impl.tools.MountPointServiceHolder;
12 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
13 import org.opendaylight.controller.md.sal.binding.api.MountPointService;
14 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
15 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.route.rev150105.RouteService;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 import static com.highstreet.technologies.odl.app.impl.tools.RPCHolder.rpc;
21
22 public class RouteProvider
23 {
24     public RouteProvider(
25             final DataBroker dataBroker, final RpcProviderRegistry rpcRegistry, final MountPointService mountService)
26     {
27         this.dataBroker = dataBroker;
28         this.rpcRegistry = rpcRegistry;
29         this.mountService = mountService;
30     }
31
32     private static final Logger LOG = LoggerFactory.getLogger(RouteProvider.class);
33     private final DataBroker dataBroker;
34     private final RpcProviderRegistry rpcRegistry;
35     private final MountPointService mountService;
36     private BindingAwareBroker.RpcRegistration<RouteService> service;
37
38     /**
39      * Method called when the blueprint container is created.
40      */
41     public void init()
42     {
43         LOG.info("RouteProvider Session Initiated --- created at 16:29-0627-2017");
44         service = rpcRegistry.addRpcImplementation(
45                 RouteService.class, rpc = new RouteRPC(dataBroker));
46         MountPointServiceHolder.setMountPointService(mountService);
47         DataBrokerHolder.setDataBroker(dataBroker);
48     }
49
50     /**
51      * Method called when the blueprint container is destroyed.
52      */
53     public void close()
54     {
55         LOG.info("RouteProvider Closed");
56         if (service != null)
57             service.close();
58     }
59 }