2 * Copyright © 2017 Orange, Inc. and others. All rights reserved.
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
9 package org.opendaylight.transportpce.servicehandler.impl;
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
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.RpcRegistration;
15 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
16 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServicehandlerService;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.StubpceListener;
18 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererListener;
19 import org.opendaylight.yangtools.concepts.ListenerRegistration;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
25 * Servicehandler Service and Notification.
26 * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
29 public class ServicehandlerProvider {
31 private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerProvider.class);
33 private final DataBroker dataBroker;
34 private final RpcProviderRegistry rpcRegistry;
35 private final NotificationService notificationService;
36 private final NotificationPublishService notificationPublishService;
38 //private ListenerRegistration<ServicehandlerListener> ServicehandlerlistenerRegistration;
39 /* Listener register for StubPce Notification. */
40 private ListenerRegistration<StubpceListener> stubPcelistenerRegistration;
41 /* Listener register for StubRender Notification. */
42 private ListenerRegistration<StubrendererListener> stubRendererlistenerRegistration;
43 private RpcRegistration<ServicehandlerService> rpcRegistration;
46 public ServicehandlerProvider(final DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry,
47 NotificationService notificationService, NotificationPublishService notificationPublishService) {
48 this.dataBroker = dataBroker;
49 this.rpcRegistry = rpcProviderRegistry;
50 this.notificationService = notificationService;
51 this.notificationPublishService = notificationPublishService;
55 * Method called when the blueprint container is created.
58 LOG.info("ServicehandlerProvider Session Initiated");
59 final ServicehandlerImpl consumer = new ServicehandlerImpl(dataBroker, rpcRegistry, notificationPublishService);
60 stubPcelistenerRegistration = notificationService.registerNotificationListener(consumer);
61 stubRendererlistenerRegistration = notificationService.registerNotificationListener(consumer);
62 rpcRegistration = rpcRegistry.addRpcImplementation(ServicehandlerService.class, consumer);
66 * Method called when the blueprint container is destroyed.
69 LOG.info("ServicehandlerProvider Closed");
70 stubPcelistenerRegistration.close();
71 stubRendererlistenerRegistration.close();
72 rpcRegistration.close();