Don't use NotificationListener (TapiProvider)
[transportpce.git] / tapi / src / main / java / org / opendaylight / transportpce / tapi / listeners / TapiServiceNotificationHandler.java
1 /*
2  * Copyright © 2021 Nokia, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.transportpce.tapi.listeners;
9
10 import java.util.Set;
11 import org.opendaylight.mdsal.binding.api.DataBroker;
12 import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener;
13 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.ServiceRpcResultSh;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 public class TapiServiceNotificationHandler {
18
19     private static final Logger LOG = LoggerFactory.getLogger(TapiServiceNotificationHandler.class);
20     private final DataBroker dataBroker;
21
22     public TapiServiceNotificationHandler(DataBroker dataBroker) {
23         this.dataBroker = dataBroker;
24     }
25
26     public CompositeListener getCompositeListener() {
27         return new CompositeListener(Set.of(
28             new CompositeListener.Component<>(ServiceRpcResultSh.class, this::onServiceRpcResultSh)));
29     }
30
31     private void onServiceRpcResultSh(ServiceRpcResultSh notification) {
32         LOG.info("Avoid dataBroker error {}", dataBroker.getClass().getCanonicalName());
33     }
34 }