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.ListenerRegistration;
23 import org.opendaylight.yangtools.concepts.Registration;
24 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
25 import org.osgi.service.component.annotations.Activate;
26 import org.osgi.service.component.annotations.Component;
27 import org.osgi.service.component.annotations.Deactivate;
28 import org.osgi.service.component.annotations.Reference;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
34 * Servicehandler Service and Notification.
35 * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
39 public class ServiceHandlerProvider {
41 private static final Logger LOG = LoggerFactory.getLogger(ServiceHandlerProvider.class);
42 private static final InstanceIdentifier<Services> SERVICE = InstanceIdentifier.builder(ServiceList.class)
43 .child(Services.class).build();
45 private final Registration pcelistenerRegistration;
46 private ListenerRegistration<DataTreeChangeListener<Services>> serviceDataTreeChangeListenerRegistration;
47 private final Registration rendererlistenerRegistration;
48 private final Registration networkmodellistenerRegistration;
49 private ServiceDataStoreOperations serviceDataStoreOperations;
52 public ServiceHandlerProvider(@Reference final DataBroker dataBroker,
53 @Reference NotificationService notificationService,
54 @Reference ServiceDataStoreOperations serviceDataStoreOperations,
55 @Reference PceNotificationHandler pceNotificationHandler,
56 @Reference RendererNotificationHandler rendererNotificationHandler,
57 @Reference NetworkModelNotificationHandler networkModelNotificationHandler,
58 @Reference DataTreeChangeListener<Services> serviceListener) {
59 this.serviceDataStoreOperations = serviceDataStoreOperations;
60 this.serviceDataStoreOperations.initialize();
61 pcelistenerRegistration = notificationService
62 .registerCompositeListener(pceNotificationHandler.getCompositeListener());
63 rendererlistenerRegistration = notificationService
64 .registerCompositeListener(rendererNotificationHandler.getCompositeListener());
65 networkmodellistenerRegistration = notificationService
66 .registerCompositeListener(networkModelNotificationHandler.getCompositeListener());
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();