9ef48f373e07f5a400802d18da6f7c30d6729242
[transportpce.git] / tests / stubpce / src / main / java / org / opendaylight / transportpce / stubpce / impl / StubpceProvider.java
1 /*
2  * Copyright © 2017 Orange, 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
9
10 package org.opendaylight.transportpce.stubpce.impl;
11
12 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
13 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
14 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
15 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
16 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
17 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.TransportpceServicepathListener;
18 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.TransportpceServicepathService;
19 import org.opendaylight.yangtools.concepts.ListenerRegistration;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22
23 /**
24  * Class to register
25  * Stubpce Service and Notification.
26  * @author <a href="mailto:martial.coulibaly@gfi.com">Martial Coulibaly</a> on behalf of Orange
27  *
28  */
29 public class StubpceProvider {
30     private static final Logger LOG = LoggerFactory.getLogger(StubpceProvider.class);
31     private final RpcProviderRegistry rpcRegistry;
32     private final NotificationPublishService notificationPublishService;
33     private final DataBroker dataBroker;
34
35
36     private BindingAwareBroker.RpcRegistration<TransportpceServicepathService> rpcRegistration;
37     private ListenerRegistration<TransportpceServicepathListener> stubPcelistenerRegistration;
38
39     public StubpceProvider(RpcProviderRegistry rpcProviderRegistry,final DataBroker dataBroker,
40             NotificationService notificationService, NotificationPublishService notificationPublishService) {
41         this.rpcRegistry = rpcProviderRegistry;
42         this.notificationPublishService = notificationPublishService;
43         this.dataBroker = dataBroker;
44     }
45
46     /**
47      * Method called when the blueprint container is created.
48      */
49     public void init() {
50         LOG.info("StubpceProvider Session Initiated");
51         final StubpceImpl consumer = new StubpceImpl(notificationPublishService,dataBroker);
52         rpcRegistration = rpcRegistry.addRpcImplementation(TransportpceServicepathService.class, consumer);
53     }
54
55     /**
56      * Method called when the blueprint container is destroyed.
57      */
58     public void close() {
59         LOG.info("StubpceProvider Closed");
60         rpcRegistration.close();
61         stubPcelistenerRegistration.close();
62     }
63 }