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.mdsal.binding.api.DataBroker;
12 import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
13 import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
14 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
15 import org.opendaylight.mdsal.binding.api.NotificationService;
16 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
17 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
18 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkmodel.rev201116.TransportpceNetworkmodelListener;
19 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.TransportpcePceListener;
20 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.TransportpceRendererListener;
21 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.OrgOpenroadmServiceService;
22 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceList;
23 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.list.Services;
24 import org.opendaylight.yangtools.concepts.ListenerRegistration;
25 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
26 import org.osgi.service.component.annotations.Activate;
27 import org.osgi.service.component.annotations.Component;
28 import org.osgi.service.component.annotations.Deactivate;
29 import org.osgi.service.component.annotations.Reference;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
35 * Servicehandler Service and Notification.
36 * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
40 public class ServicehandlerProvider {
42 private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerProvider.class);
43 private static final InstanceIdentifier<Services> SERVICE = InstanceIdentifier.builder(ServiceList.class)
44 .child(Services.class).build();
46 private ListenerRegistration<TransportpcePceListener> pcelistenerRegistration;
47 private ListenerRegistration<DataTreeChangeListener<Services>> serviceDataTreeChangeListenerRegistration;
48 private ListenerRegistration<TransportpceRendererListener> rendererlistenerRegistration;
49 private ListenerRegistration<TransportpceNetworkmodelListener> networkmodellistenerRegistration;
50 private ServiceDataStoreOperations serviceDataStoreOperations;
53 public ServicehandlerProvider(@Reference final DataBroker dataBroker,
54 @Reference NotificationService notificationService,
55 @Reference ServiceDataStoreOperations serviceDataStoreOperations,
56 @Reference TransportpcePceListener pceListenerImpl,
57 @Reference TransportpceRendererListener rendererListenerImpl,
58 @Reference TransportpceNetworkmodelListener networkModelListenerImpl,
59 @Reference NotificationPublishService notificationPublishService,
60 @Reference OrgOpenroadmServiceService servicehandler,
61 @Reference DataTreeChangeListener<Services> serviceListener) {
62 this.serviceDataStoreOperations = serviceDataStoreOperations;
63 this.serviceDataStoreOperations.initialize();
64 pcelistenerRegistration = notificationService.registerNotificationListener(pceListenerImpl);
65 rendererlistenerRegistration = notificationService.registerNotificationListener(rendererListenerImpl);
66 networkmodellistenerRegistration = notificationService.registerNotificationListener(networkModelListenerImpl);
67 serviceDataTreeChangeListenerRegistration = dataBroker.registerDataTreeChangeListener(
68 DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, SERVICE), serviceListener);
69 LOG.info("ServicehandlerProvider Session Initiated");
70 LOG.info("Transportpce controller started");
74 * Method called when the blueprint container is destroyed.
78 LOG.info("ServicehandlerProvider Closed");
79 pcelistenerRegistration.close();
80 serviceDataTreeChangeListenerRegistration.close();
81 rendererlistenerRegistration.close();
82 networkmodellistenerRegistration.close();