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.NotificationService;
15 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
16 import org.opendaylight.transportpce.servicehandler.listeners.NetworkModelNotificationHandler;
17 import org.opendaylight.transportpce.servicehandler.listeners.PceNotificationHandler;
18 import org.opendaylight.transportpce.servicehandler.listeners.RendererNotificationHandler;
19 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
20 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceList;
21 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.list.Services;
22 import org.opendaylight.yangtools.concepts.Registration;
23 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
24 import org.osgi.service.component.annotations.Activate;
25 import org.osgi.service.component.annotations.Component;
26 import org.osgi.service.component.annotations.Deactivate;
27 import org.osgi.service.component.annotations.Reference;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
33 * Servicehandler Service and Notification.
34 * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
38 public class ServiceHandlerProvider {
40 private static final Logger LOG = LoggerFactory.getLogger(ServiceHandlerProvider.class);
41 private static final InstanceIdentifier<Services> SERVICE = InstanceIdentifier.create(ServiceList.class)
42 .child(Services.class);
44 private final Registration pcelistenerRegistration;
45 private Registration serviceListListenerRegistration;
46 private final Registration rendererlistenerRegistration;
47 private final Registration networkmodellistenerRegistration;
48 private ServiceDataStoreOperations serviceDataStoreOperations;
51 public ServiceHandlerProvider(@Reference final DataBroker dataBroker,
52 @Reference NotificationService notificationService,
53 @Reference ServiceDataStoreOperations serviceDataStoreOperations,
54 @Reference PceNotificationHandler pceNotificationHandler,
55 @Reference RendererNotificationHandler rendererNotificationHandler,
56 @Reference NetworkModelNotificationHandler networkModelNotificationHandler,
57 @Reference DataTreeChangeListener<Services> serviceListener) {
58 this.serviceDataStoreOperations = serviceDataStoreOperations;
59 this.serviceDataStoreOperations.initialize();
60 pcelistenerRegistration = notificationService
61 .registerCompositeListener(pceNotificationHandler.getCompositeListener());
62 rendererlistenerRegistration = notificationService
63 .registerCompositeListener(rendererNotificationHandler.getCompositeListener());
64 networkmodellistenerRegistration = notificationService
65 .registerCompositeListener(networkModelNotificationHandler.getCompositeListener());
66 final var serviceListId = DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, SERVICE);
67 serviceListListenerRegistration = dataBroker.registerTreeChangeListener(serviceListId, serviceListener);
68 LOG.info("ServicehandlerProvider Session Initiated");
69 LOG.info("Transportpce controller started");
73 * Method called when the blueprint container is destroyed.
77 LOG.info("ServicehandlerProvider Closed");
78 pcelistenerRegistration.close();
79 serviceListListenerRegistration.close();
80 rendererlistenerRegistration.close();
81 networkmodellistenerRegistration.close();