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