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.DataTreeIdentifier;
13 import org.opendaylight.mdsal.binding.api.NotificationService;
14 import org.opendaylight.mdsal.binding.api.RpcProviderService;
15 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
16 import org.opendaylight.transportpce.servicehandler.listeners.NetworkModelListenerImpl;
17 import org.opendaylight.transportpce.servicehandler.listeners.PceListenerImpl;
18 import org.opendaylight.transportpce.servicehandler.listeners.RendererListenerImpl;
19 import org.opendaylight.transportpce.servicehandler.listeners.ServiceListener;
20 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
21 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkmodel.rev201116.TransportpceNetworkmodelListener;
22 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220615.TransportpcePceListener;
23 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.TransportpceRendererListener;
24 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OrgOpenroadmServiceService;
25 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.ServiceList;
26 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.Services;
27 import org.opendaylight.yangtools.concepts.ListenerRegistration;
28 import org.opendaylight.yangtools.concepts.ObjectRegistration;
29 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
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
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 DataBroker dataBroker;
46 private final RpcProviderService rpcService;
47 private final NotificationService notificationService;
48 private ListenerRegistration<TransportpcePceListener> pcelistenerRegistration;
49 private ListenerRegistration<ServiceListener> serviceDataTreeChangeListenerRegistration;
50 private ListenerRegistration<TransportpceRendererListener> rendererlistenerRegistration;
51 private ListenerRegistration<TransportpceNetworkmodelListener> networkmodellistenerRegistration;
52 private ObjectRegistration<OrgOpenroadmServiceService> rpcRegistration;
53 private ServiceDataStoreOperations serviceDataStoreOperations;
54 private PceListenerImpl pceListenerImpl;
55 private ServiceListener serviceListener;
56 private RendererListenerImpl rendererListenerImpl;
57 private NetworkModelListenerImpl networkModelListenerImpl;
58 private ServicehandlerImpl servicehandler;
60 public ServicehandlerProvider(final DataBroker dataBroker, RpcProviderService rpcProviderService,
61 NotificationService notificationService, ServiceDataStoreOperations serviceDataStoreOperations,
62 PceListenerImpl pceListenerImpl, ServiceListener serviceListener, RendererListenerImpl rendererListenerImpl,
63 NetworkModelListenerImpl networkModelListenerImpl, ServicehandlerImpl servicehandler) {
64 this.dataBroker = dataBroker;
65 this.rpcService = rpcProviderService;
66 this.notificationService = notificationService;
67 this.serviceDataStoreOperations = serviceDataStoreOperations;
68 this.serviceDataStoreOperations.initialize();
69 this.pceListenerImpl = pceListenerImpl;
70 this.serviceListener = serviceListener;
71 this.rendererListenerImpl = rendererListenerImpl;
72 this.networkModelListenerImpl = networkModelListenerImpl;
73 this.servicehandler = servicehandler;
77 * Method called when the blueprint container is created.
80 LOG.info("ServicehandlerProvider Session Initiated");
81 pcelistenerRegistration = notificationService.registerNotificationListener(pceListenerImpl);
82 serviceDataTreeChangeListenerRegistration = dataBroker.registerDataTreeChangeListener(
83 DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, SERVICE), serviceListener);
84 rendererlistenerRegistration = notificationService.registerNotificationListener(rendererListenerImpl);
85 networkmodellistenerRegistration = notificationService.registerNotificationListener(networkModelListenerImpl);
86 rpcRegistration = rpcService.registerRpcImplementation(OrgOpenroadmServiceService.class, servicehandler);
90 * Method called when the blueprint container is destroyed.
93 LOG.info("ServicehandlerProvider Closed");
94 pcelistenerRegistration.close();
95 serviceDataTreeChangeListenerRegistration.close();
96 rendererlistenerRegistration.close();
97 networkmodellistenerRegistration.close();
98 rpcRegistration.close();