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.stubpce.rev170426.StubpceListener;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererListener;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.OrgOpenroadmServiceService;
19 import org.opendaylight.yangtools.concepts.ListenerRegistration;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
25 * Servicehandler Service and Notification.
27 * @author <a href="mailto:martial.coulibaly@gfi.com">Martial Coulibaly</a> on behalf of Orange
30 public class ServicehandlerProvider {
32 private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerProvider.class);
34 private final DataBroker dataBroker;
35 private final RpcProviderRegistry rpcRegistry;
36 private final NotificationService notificationService;
37 private final NotificationPublishService notificationPublishService;
39 /** Listener register for TransportpceService Notification. */
40 private ListenerRegistration<StubpceListener> stubpcelistenerRegistration;
41 private ListenerRegistration<StubrendererListener> stubrendererlistenerRegistration;
42 private RpcRegistration<OrgOpenroadmServiceService> rpcRegistration;
45 public ServicehandlerProvider(final DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry,
46 NotificationService notificationService, NotificationPublishService notificationPublishService) {
47 this.dataBroker = dataBroker;
48 this.rpcRegistry = rpcProviderRegistry;
49 this.notificationService = notificationService;
50 this.notificationPublishService = notificationPublishService;
54 * Method called when the blueprint container is created.
57 LOG.info("ServicehandlerProvider Session Initiated");
58 final ServicehandlerImpl consumer = new ServicehandlerImpl(dataBroker, rpcRegistry, notificationPublishService);
59 stubpcelistenerRegistration = notificationService.registerNotificationListener(consumer);
60 stubrendererlistenerRegistration = notificationService.registerNotificationListener(consumer);
61 rpcRegistration = rpcRegistry.addRpcImplementation(OrgOpenroadmServiceService.class, consumer);
65 * Method called when the blueprint container is destroyed.
68 LOG.info("ServicehandlerProvider Closed");
69 stubpcelistenerRegistration.close();
70 stubrendererlistenerRegistration.close();
71 rpcRegistration.close();