Initial commit for ServiceHandler
[transportpce.git] / 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.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.opendaylight.transportpce.stubpce.rev170426.StubpceListener;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.StubpceService;
18 import org.opendaylight.yangtools.concepts.ListenerRegistration;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 /*
23  * Class to register
24  * Stubpce Service & Notification.
25  * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
26  *
27  */
28 public class StubpceProvider {
29     private static final Logger LOG = LoggerFactory.getLogger(StubpceProvider.class);
30     private final RpcProviderRegistry rpcRegistry;
31     private final NotificationPublishService notificationPublishService;
32
33
34     private BindingAwareBroker.RpcRegistration<StubpceService> rpcRegistration;
35     private ListenerRegistration<StubpceListener> stubPcelistenerRegistration;
36
37     public StubpceProvider(RpcProviderRegistry rpcProviderRegistry,
38         NotificationService notificationService,
39         NotificationPublishService notificationPublishService) {
40         this.rpcRegistry = rpcProviderRegistry;
41         this.notificationPublishService = notificationPublishService;
42     }
43
44     /*
45      * Method called when the blueprint container is created.
46      */
47     public void init() {
48         LOG.info("StubpceProvider Session Initiated");
49         final StubpceImpl consumer = new StubpceImpl(notificationPublishService);
50         rpcRegistration = rpcRegistry.addRpcImplementation(StubpceService.class, consumer);
51     }
52
53     /*
54      * Method called when the blueprint container is destroyed.
55      */
56     public void close() {
57         LOG.info("StubpceProvider Closed");
58         rpcRegistration.close();
59         stubPcelistenerRegistration.close();
60     }
61 }