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.rev170930.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.yang.gen.v1.http.org.openroadm.service.rev161014.OrgOpenroadmServiceService;
20 import org.opendaylight.yangtools.concepts.ListenerRegistration;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
26 * Servicehandler Service and Notification.
28 * @author <a href="mailto:martial.coulibaly@gfi.com">Martial Coulibaly</a> on behalf of Orange
31 public class ServicehandlerProvider {
33 private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerProvider.class);
35 private final DataBroker dataBroker;
36 private final RpcProviderRegistry rpcRegistry;
37 private final NotificationService notificationService;
38 private final NotificationPublishService notificationPublishService;
40 /** Listener register for TransportpceService Notification. */
41 private ListenerRegistration<StubpceListener> stubpcelistenerRegistration;
42 private ListenerRegistration<StubrendererListener> stubrendererlistenerRegistration;
43 private RpcRegistration<OrgOpenroadmServiceService> rpcRegistration;
44 private RpcRegistration<ServicehandlerService> rpcRegistrationServiceHandler;
47 public ServicehandlerProvider(final DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry,
48 NotificationService notificationService, NotificationPublishService notificationPublishService) {
49 this.dataBroker = dataBroker;
50 this.rpcRegistry = rpcProviderRegistry;
51 this.notificationService = notificationService;
52 this.notificationPublishService = notificationPublishService;
56 * Method called when the blueprint container is created.
59 LOG.info("ServicehandlerProvider Session Initiated");
60 final ServicehandlerImpl consumer = new ServicehandlerImpl(dataBroker, rpcRegistry, notificationPublishService);
61 stubpcelistenerRegistration = notificationService.registerNotificationListener(consumer);
62 stubrendererlistenerRegistration = notificationService.registerNotificationListener(consumer);
63 rpcRegistration = rpcRegistry.addRpcImplementation(OrgOpenroadmServiceService.class, consumer);
64 rpcRegistrationServiceHandler = rpcRegistry.addRpcImplementation(ServicehandlerService.class, consumer);
68 * Method called when the blueprint container is destroyed.
71 LOG.info("ServicehandlerProvider Closed");
72 stubpcelistenerRegistration.close();
73 stubrendererlistenerRegistration.close();
74 rpcRegistration.close();
75 rpcRegistrationServiceHandler.close();