Don't use NotificationListener (TapiProvider) 21/108121/17
authorMatej Sramcik <matej.sramcik@pantheon.tech>
Mon, 2 Oct 2023 08:59:19 +0000 (10:59 +0200)
committerMatej Sramcik <matej.sramcik@pantheon.tech>
Mon, 23 Oct 2023 10:00:57 +0000 (12:00 +0200)
Don't use NotificationListener in classes used by TapiProvider.
This is a part of NotificationListener to Listener<?> migration.

JIRA: TRNSPRTPCE-756
Change-Id: I087bc8dacbc710da39c308dc5fbef7028d0d6d56
Signed-off-by: Matej Sramcik <matej.sramcik@pantheon.tech>
lighty/src/main/java/io/lighty/controllers/tpce/module/TransportPCEImpl.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/connectivity/TapiConnectivityImpl.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/TapiProvider.java
tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiNetworkModelNotificationHandler.java [moved from tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiNetworkModelListenerImpl.java with 98% similarity]
tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiPceNotificationHandler.java [moved from tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiPceListenerImpl.java with 99% similarity]
tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiRendererNotificationHandler.java [moved from tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiRendererListenerImpl.java with 96% similarity]
tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiServiceNotificationHandler.java [moved from tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiServiceHandlerListenerImpl.java with 61% similarity]
tapi/src/test/java/org/opendaylight/transportpce/tapi/connectivity/TapiConnectivityImplTest.java
tapi/src/test/java/org/opendaylight/transportpce/tapi/provider/TapiProviderTest.java

index d6506204a144d78244b5b3c8a1f9260a38f08c9b..d6e44ad9a80c9e26135e5101e5ef44e0a049791f 100644 (file)
@@ -67,7 +67,7 @@ import org.opendaylight.transportpce.servicehandler.listeners.ServiceListener;
 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
 import org.opendaylight.transportpce.tapi.impl.TapiProvider;
-import org.opendaylight.transportpce.tapi.listeners.TapiNetworkModelListenerImpl;
+import org.opendaylight.transportpce.tapi.listeners.TapiNetworkModelNotificationHandler;
 import org.opendaylight.transportpce.tapi.topology.TapiNetworkModelService;
 import org.opendaylight.transportpce.tapi.topology.TapiNetworkModelServiceImpl;
 import org.opendaylight.transportpce.tapi.topology.TapiNetworkUtilsImpl;
@@ -194,7 +194,7 @@ public class TransportPCEImpl extends AbstractLightyModule implements TransportP
             new TapiNetworkUtilsImpl(lgServRPS, networkTransaction, tapiLink);
             tapiProvider = initTapi(
                     lightyServices, servicehandler, networkTransaction, serviceDataStoreOperations,
-                    new TapiNetworkModelListenerImpl(
+                    new TapiNetworkModelNotificationHandler(
                         networkTransaction, lgServBNPS),
                     tapiLink,
                     new TapiNetworkModelServiceImpl(
@@ -249,13 +249,13 @@ public class TransportPCEImpl extends AbstractLightyModule implements TransportP
     private TapiProvider initTapi(
             LightyServices lightyServices, OrgOpenroadmServiceService servicehandler,
             NetworkTransactionService networkTransactionService, ServiceDataStoreOperations serviceDataStoreOperations,
-            TapiNetworkModelListenerImpl tapiNetworkModelListenerImpl, TapiLink tapiLink,
+            TapiNetworkModelNotificationHandler tapiNetworkModelNotificationHandler, TapiLink tapiLink,
             TapiNetworkModelService tapiNetworkModelService) {
         return new TapiProvider(
             lightyServices.getBindingDataBroker(), lightyServices.getRpcProviderService(),
             lightyServices.getNotificationService(), lightyServices.getBindingNotificationPublishService(),
             networkTransactionService, servicehandler, serviceDataStoreOperations,
-            tapiNetworkModelListenerImpl, tapiNetworkModelService);
+            tapiNetworkModelNotificationHandler, tapiNetworkModelService);
     }
 
     private void initRenderer(
index 6b750a188a27935fbabda9bb3192cb954a338f0e..79a9dc7c7db586a1ba9fecc0e96bb1f25d5bd13d 100644 (file)
@@ -16,8 +16,8 @@ import java.util.UUID;
 import java.util.concurrent.ExecutionException;
 import org.opendaylight.transportpce.common.OperationResult;
 import org.opendaylight.transportpce.common.ResponseCodes;
-import org.opendaylight.transportpce.tapi.listeners.TapiPceListenerImpl;
-import org.opendaylight.transportpce.tapi.listeners.TapiRendererListenerImpl;
+import org.opendaylight.transportpce.tapi.listeners.TapiPceNotificationHandler;
+import org.opendaylight.transportpce.tapi.listeners.TapiRendererNotificationHandler;
 import org.opendaylight.transportpce.tapi.utils.TapiContext;
 import org.opendaylight.transportpce.tapi.validation.CreateConnectivityServiceValidation;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.RpcActions;
@@ -102,12 +102,12 @@ public class TapiConnectivityImpl implements TapiConnectivityService {
     private OrgOpenroadmServiceService serviceHandler;
     private final TapiContext tapiContext;
     private final ConnectivityUtils connectivityUtils;
-    private TapiPceListenerImpl pceListenerImpl;
-    private TapiRendererListenerImpl rendererListenerImpl;
+    private TapiPceNotificationHandler pceListenerImpl;
+    private TapiRendererNotificationHandler rendererListenerImpl;
 
     public TapiConnectivityImpl(OrgOpenroadmServiceService serviceHandler, TapiContext tapiContext,
-                                ConnectivityUtils connectivityUtils, TapiPceListenerImpl pceListenerImpl,
-                                TapiRendererListenerImpl rendererListenerImpl) {
+                                ConnectivityUtils connectivityUtils, TapiPceNotificationHandler pceListenerImpl,
+                                TapiRendererNotificationHandler rendererListenerImpl) {
         LOG.info("inside TapiImpl constructor");
         this.serviceHandler = serviceHandler;
         this.tapiContext = tapiContext;
index 880ef0383d4e846193f7142481382b9279086b73..657b9c200a4c2f8fe4912b354f586601ef41c36d 100644 (file)
@@ -22,9 +22,10 @@ import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
 import org.opendaylight.transportpce.tapi.connectivity.ConnectivityUtils;
 import org.opendaylight.transportpce.tapi.connectivity.TapiConnectivityImpl;
-import org.opendaylight.transportpce.tapi.listeners.TapiPceListenerImpl;
-import org.opendaylight.transportpce.tapi.listeners.TapiRendererListenerImpl;
-import org.opendaylight.transportpce.tapi.listeners.TapiServiceHandlerListenerImpl;
+import org.opendaylight.transportpce.tapi.listeners.TapiNetworkModelNotificationHandler;
+import org.opendaylight.transportpce.tapi.listeners.TapiPceNotificationHandler;
+import org.opendaylight.transportpce.tapi.listeners.TapiRendererNotificationHandler;
+import org.opendaylight.transportpce.tapi.listeners.TapiServiceNotificationHandler;
 import org.opendaylight.transportpce.tapi.topology.TapiNetconfTopologyListener;
 import org.opendaylight.transportpce.tapi.topology.TapiNetworkModelService;
 import org.opendaylight.transportpce.tapi.topology.TapiOrLinkListener;
@@ -36,21 +37,18 @@ import org.opendaylight.transportpce.tapi.utils.TapiInitialORMapping;
 import org.opendaylight.transportpce.tapi.utils.TapiLink;
 import org.opendaylight.transportpce.tapi.utils.TapiLinkImpl;
 import org.opendaylight.transportpce.tapi.utils.TapiListener;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.TransportpcePceListener;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.Network;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.Nodes;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.TransportpceRendererListener;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.TransportpceServicehandlerListener;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.tapinetworkutils.rev210408.TransportpceTapinetworkutilsService;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.OrgOpenroadmServiceService;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.TapiNotificationListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.tapi.rev180928.ServiceInterfacePoints;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.osgi.service.component.annotations.Activate;
@@ -82,12 +80,13 @@ public class TapiProvider {
     private final NetworkTransactionService networkTransactionService;
     private final OrgOpenroadmServiceService serviceHandler;
     private final ServiceDataStoreOperations serviceDataStoreOperations;
+    private ObjectRegistration<TransportpceTapinetworkutilsService> tapiNetworkutilsServiceRpcRegistration;
     private List<Registration> listeners;
-    private ListenerRegistration<TransportpcePceListener> pcelistenerRegistration;
-    private ListenerRegistration<TransportpceRendererListener> rendererlistenerRegistration;
-    private ListenerRegistration<TransportpceServicehandlerListener> servicehandlerlistenerRegistration;
-    private ListenerRegistration<TapiNotificationListener> tapinetworkmodellistenerRegistration;
     private List<Registration> rpcRegistrations = new ArrayList<>();
+    private Registration pcelistenerRegistration;
+    private Registration rendererlistenerRegistration;
+    private Registration servicehandlerlistenerRegistration;
+    private Registration tapinetworkmodellistenerRegistration;
 
     @Activate
     public TapiProvider(@Reference DataBroker dataBroker,
@@ -97,7 +96,7 @@ public class TapiProvider {
             @Reference NetworkTransactionService networkTransactionService,
             @Reference OrgOpenroadmServiceService serviceHandler,
             @Reference ServiceDataStoreOperations serviceDataStoreOperations,
-            @Reference TapiNotificationListener tapiNetworkModelListenerImpl,
+            @Reference TapiNetworkModelNotificationHandler tapiNetworkModelNotificationHandler,
             @Reference TapiNetworkModelService tapiNetworkModelServiceImpl) {
         this.dataBroker = dataBroker;
         this.networkTransactionService = networkTransactionService;
@@ -114,8 +113,8 @@ public class TapiProvider {
                 tapiContext, this.serviceDataStoreOperations);
         tapiInitialORMapping.performTopoInitialMapping();
         tapiInitialORMapping.performServInitialMapping();
-        TapiPceListenerImpl pceListenerImpl = new TapiPceListenerImpl(dataBroker);
-        TapiRendererListenerImpl rendererListenerImpl = new TapiRendererListenerImpl(dataBroker,
+        TapiPceNotificationHandler pceListenerImpl = new TapiPceNotificationHandler(dataBroker);
+        TapiRendererNotificationHandler rendererListenerImpl = new TapiRendererNotificationHandler(dataBroker,
                 notificationPublishService);
 
         TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(this.serviceHandler, tapiContext,
@@ -143,13 +142,14 @@ public class TapiProvider {
                         InstanceIdentifier.create(ServiceInterfacePoints.class)),
                 tapiListener));
         // Notification Listener
-        pcelistenerRegistration = notificationService.registerNotificationListener(pceListenerImpl);
-        rendererlistenerRegistration = notificationService.registerNotificationListener(rendererListenerImpl);
-        TapiServiceHandlerListenerImpl serviceHandlerListenerImpl = new TapiServiceHandlerListenerImpl(dataBroker);
+        pcelistenerRegistration = notificationService.registerCompositeListener(pceListenerImpl.getCompositeListener());
+        rendererlistenerRegistration = notificationService
+            .registerCompositeListener(rendererListenerImpl.getCompositeListener());
+        TapiServiceNotificationHandler serviceHandlerListenerImpl = new TapiServiceNotificationHandler(dataBroker);
         servicehandlerlistenerRegistration = notificationService
-            .registerNotificationListener(serviceHandlerListenerImpl);
+            .registerCompositeListener(serviceHandlerListenerImpl.getCompositeListener());
         tapinetworkmodellistenerRegistration = notificationService
-            .registerNotificationListener(tapiNetworkModelListenerImpl);
+            .registerCompositeListener(tapiNetworkModelNotificationHandler.getCompositeListener());
     }
 
     /**
similarity index 98%
rename from tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiNetworkModelListenerImpl.java
rename to tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiNetworkModelNotificationHandler.java
index e226864a7636da925aaef0bd8a09eec0271d6b1c..8f5a7018839d10c10eb38f4c57fad142125c822c 100644 (file)
@@ -19,10 +19,12 @@ import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
+import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.ExecutionException;
 import java.util.stream.Collectors;
 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.transportpce.tapi.TapiStringConstants;
@@ -50,7 +52,6 @@ import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev18121
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.Notification;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.NotificationType;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.ObjectType;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.TapiNotificationListener;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributes;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributesBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.notification.ChangedAttributesKey;
@@ -74,10 +75,10 @@ import org.osgi.service.component.annotations.Reference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@Component
-public class TapiNetworkModelListenerImpl implements TapiNotificationListener {
+@Component(service = TapiNetworkModelNotificationHandler.class)
+public class TapiNetworkModelNotificationHandler {
 
-    private static final Logger LOG = LoggerFactory.getLogger(TapiNetworkModelListenerImpl.class);
+    private static final Logger LOG = LoggerFactory.getLogger(TapiNetworkModelNotificationHandler.class);
     private final NetworkTransactionService networkTransactionService;
     private final NotificationPublishService notificationPublishService;
     private final List<ConnectivityService> connectivityServiceChanges = new ArrayList<>();
@@ -86,7 +87,7 @@ public class TapiNetworkModelListenerImpl implements TapiNotificationListener {
     private final List<LayerProtocolName> orderedServiceLayerList;
 
     @Activate
-    public TapiNetworkModelListenerImpl(@Reference NetworkTransactionService networkTransactionService,
+    public TapiNetworkModelNotificationHandler(@Reference NetworkTransactionService networkTransactionService,
             @Reference NotificationPublishService notificationPublishService) {
         this.networkTransactionService = networkTransactionService;
         this.notificationPublishService = notificationPublishService;
@@ -95,8 +96,12 @@ public class TapiNetworkModelListenerImpl implements TapiNotificationListener {
         LOG.debug("TapiNetworkModelListenerImpl instantiated");
     }
 
-    @Override
-    public void onNotification(Notification notification) {
+    public CompositeListener getCompositeListener() {
+        return new CompositeListener(Set.of(
+            new CompositeListener.Component<>(Notification.class, this::onNotification)));
+    }
+
+    private void onNotification(Notification notification) {
         LOG.info("Received network model notification {}", notification);
         if (notification.getNotificationType() == NotificationType.ATTRIBUTEVALUECHANGE
                 && notification.getTargetObjectType() == ObjectType.NODEEDGEPOINT) {
similarity index 99%
rename from tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiPceListenerImpl.java
rename to tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiPceNotificationHandler.java
index ab977f070f81d9dededc048b639b43b15a7bfb89..b224491515de04d55adb98e469383df493f8b507 100644 (file)
@@ -15,16 +15,17 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
+import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.ExecutionException;
 import java.util.stream.Collectors;
 import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.transportpce.tapi.TapiStringConstants;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.ServicePathRpcResult;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.TransportpcePceListener;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.service.path.rpc.result.PathDescription;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.service.path.rpc.result.PathDescriptionBuilder;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.Network;
@@ -80,9 +81,9 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class TapiPceListenerImpl implements TransportpcePceListener {
+public class TapiPceNotificationHandler {
 
-    private static final Logger LOG = LoggerFactory.getLogger(TapiPceListenerImpl.class);
+    private static final Logger LOG = LoggerFactory.getLogger(TapiPceNotificationHandler.class);
 
     private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
         .getBytes(Charset.forName("UTF-8"))).toString());
@@ -99,7 +100,7 @@ public class TapiPceListenerImpl implements TransportpcePceListener {
     private Connection topConnXpdrXpdrPhtn;
     private Connection topConnXpdrXpdrOdu;
 
-    public TapiPceListenerImpl(DataBroker dataBroker) {
+    public TapiPceNotificationHandler(DataBroker dataBroker) {
         this.connectionFullMap = new HashMap<>();
         this.dataBroker = dataBroker;
         this.networkTransactionService = new NetworkTransactionImpl(this.dataBroker);
@@ -108,8 +109,12 @@ public class TapiPceListenerImpl implements TransportpcePceListener {
         this.topConnXpdrXpdrOdu = null;
     }
 
-    @Override
-    public void onServicePathRpcResult(ServicePathRpcResult notification) {
+    public CompositeListener getCompositeListener() {
+        return new CompositeListener(Set.of(
+            new CompositeListener.Component<>(ServicePathRpcResult.class, this::onServicePathRpcResult)));
+    }
+
+    private void onServicePathRpcResult(ServicePathRpcResult notification) {
         if (compareServicePathRpcResult(notification)) {
             LOG.warn("ServicePathRpcResult already wired !");
             return;
similarity index 96%
rename from tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiRendererListenerImpl.java
rename to tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiRendererNotificationHandler.java
index 4b4006815763172763c52d5474195f81dead3b0a..a41e9428bc868532ffd446d5ef971de64f328787 100644 (file)
@@ -15,15 +15,16 @@ import java.time.format.DateTimeFormatter;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
+import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.ExecutionException;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.RendererRpcResultSp;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.TransportpceRendererListener;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev230726.PublishTapiNotificationService;
 import org.opendaylight.yang.gen.v1.nbi.notifications.rev230726.PublishTapiNotificationServiceBuilder;
 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState;
@@ -53,23 +54,28 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class TapiRendererListenerImpl implements TransportpceRendererListener {
+public class TapiRendererNotificationHandler {
 
-    private static final Logger LOG = LoggerFactory.getLogger(TapiRendererListenerImpl.class);
+    private static final Logger LOG = LoggerFactory.getLogger(TapiRendererNotificationHandler.class);
     private final DataBroker dataBroker;
     private Uuid serviceUuid;
     private RendererRpcResultSp serviceRpcResultSp;
     private final NetworkTransactionService networkTransactionService;
     private final NotificationPublishService notificationPublishService;
 
-    public TapiRendererListenerImpl(DataBroker dataBroker, NotificationPublishService notificationPublishService) {
+    public TapiRendererNotificationHandler(DataBroker dataBroker,
+            NotificationPublishService notificationPublishService) {
         this.dataBroker = dataBroker;
         this.networkTransactionService = new NetworkTransactionImpl(this.dataBroker);
         this.notificationPublishService = notificationPublishService;
     }
 
-    @Override
-    public void onRendererRpcResultSp(RendererRpcResultSp notification) {
+    public CompositeListener getCompositeListener() {
+        return new CompositeListener(Set.of(
+            new CompositeListener.Component<>(RendererRpcResultSp.class, this::onRendererRpcResultSp)));
+    }
+
+    private void onRendererRpcResultSp(RendererRpcResultSp notification) {
         if (compareServiceRpcResultSp(notification)) {
             LOG.warn("ServiceRpcResultSp already wired !");
             return;
similarity index 61%
rename from tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiServiceHandlerListenerImpl.java
rename to tapi/src/main/java/org/opendaylight/transportpce/tapi/listeners/TapiServiceNotificationHandler.java
index 03ad2e5e397630f1f8a30d9557c4d4e77b862ff6..b1930d8726d13e2da6982a9092cec7e811080ae6 100644 (file)
@@ -7,24 +7,28 @@
  */
 package org.opendaylight.transportpce.tapi.listeners;
 
+import java.util.Set;
 import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener;
 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.ServiceRpcResultSh;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.TransportpceServicehandlerListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class TapiServiceHandlerListenerImpl implements TransportpceServicehandlerListener {
+public class TapiServiceNotificationHandler {
 
-    private static final Logger LOG = LoggerFactory.getLogger(TapiServiceHandlerListenerImpl.class);
+    private static final Logger LOG = LoggerFactory.getLogger(TapiServiceNotificationHandler.class);
     private final DataBroker dataBroker;
 
-    public TapiServiceHandlerListenerImpl(DataBroker dataBroker) {
+    public TapiServiceNotificationHandler(DataBroker dataBroker) {
         this.dataBroker = dataBroker;
+    }
 
+    public CompositeListener getCompositeListener() {
+        return new CompositeListener(Set.of(
+            new CompositeListener.Component<>(ServiceRpcResultSh.class, this::onServiceRpcResultSh)));
     }
 
-    @Override
-    public void onServiceRpcResultSh(ServiceRpcResultSh notification) {
+    private void onServiceRpcResultSh(ServiceRpcResultSh notification) {
         LOG.info("Avoid dataBroker error {}", dataBroker.getClass().getCanonicalName());
     }
 }
index 70a9adcb392808f36f877f2d889c9b10d29f6f69..992514f99b49986242073c46f2e6f7c0088653f7 100644 (file)
@@ -39,9 +39,9 @@ import org.opendaylight.transportpce.servicehandler.listeners.PceListener;
 import org.opendaylight.transportpce.servicehandler.listeners.RendererListener;
 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperationsImpl;
-import org.opendaylight.transportpce.tapi.listeners.TapiPceListenerImpl;
-import org.opendaylight.transportpce.tapi.listeners.TapiRendererListenerImpl;
-import org.opendaylight.transportpce.tapi.listeners.TapiServiceHandlerListenerImpl;
+import org.opendaylight.transportpce.tapi.listeners.TapiPceNotificationHandler;
+import org.opendaylight.transportpce.tapi.listeners.TapiRendererNotificationHandler;
+import org.opendaylight.transportpce.tapi.listeners.TapiServiceNotificationHandler;
 import org.opendaylight.transportpce.tapi.topology.TopologyUtils;
 import org.opendaylight.transportpce.tapi.utils.TapiConnectivityDataUtils;
 import org.opendaylight.transportpce.tapi.utils.TapiContext;
@@ -74,11 +74,11 @@ public class TapiConnectivityImplTest extends AbstractTest {
     @Mock
     private NotificationPublishService notificationPublishService;
     @Mock
-    private TapiPceListenerImpl tapipceListenerImpl;
+    private TapiPceNotificationHandler tapipceNotificationHandler;
     @Mock
-    private TapiRendererListenerImpl tapirendererListenerImpl;
+    private TapiRendererNotificationHandler tapirendererNotificationHandler;
     @Mock
-    private TapiServiceHandlerListenerImpl tapiserviceHandlerListenerImpl;
+    private TapiServiceNotificationHandler tapiserviceNotificationHandler;
     @Mock
     private PceListener pceListenerImpl;
     @Mock
@@ -137,7 +137,7 @@ public class TapiConnectivityImplTest extends AbstractTest {
             networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
 
         TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(serviceHandler, tapiContext, connectivityUtils,
-            tapipceListenerImpl, tapirendererListenerImpl);
+            tapipceNotificationHandler, tapirendererNotificationHandler);
 
         ListenableFuture<RpcResult<CreateConnectivityServiceOutput>> result =
             tapiConnectivity.createConnectivityService(new CreateConnectivityServiceInputBuilder().build());
@@ -165,7 +165,7 @@ public class TapiConnectivityImplTest extends AbstractTest {
         when(pathComputationService.pathComputationRequest(any())).thenReturn(Futures.immediateFuture(any()));
 
         TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(serviceHandler, tapiContext, connectivityUtils,
-            tapipceListenerImpl, tapirendererListenerImpl);
+            tapipceNotificationHandler, tapirendererNotificationHandler);
         ListenableFuture<RpcResult<CreateConnectivityServiceOutput>> result =
             tapiConnectivity.createConnectivityService(input);
         result.addListener(new Runnable() {
@@ -188,7 +188,7 @@ public class TapiConnectivityImplTest extends AbstractTest {
             networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
 
         TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(serviceHandler, tapiContext, connectivityUtils,
-            tapipceListenerImpl, tapirendererListenerImpl);
+            tapipceNotificationHandler, tapirendererNotificationHandler);
 
         ListenableFuture<RpcResult<DeleteConnectivityServiceOutput>> result =
             tapiConnectivity.deleteConnectivityService(new DeleteConnectivityServiceInputBuilder().build());
@@ -213,7 +213,7 @@ public class TapiConnectivityImplTest extends AbstractTest {
             networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
 
         TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(serviceHandler, tapiContext, connectivityUtils,
-            tapipceListenerImpl, tapirendererListenerImpl);
+            tapipceNotificationHandler, tapirendererNotificationHandler);
         ListenableFuture<RpcResult<DeleteConnectivityServiceOutput>> result =
             tapiConnectivity.deleteConnectivityService(input);
         result.addListener(new Runnable() {
@@ -238,7 +238,7 @@ public class TapiConnectivityImplTest extends AbstractTest {
             networkModelListenerImpl, serviceDataStoreOperations, catalogDataStoreOperations);
 
         TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(serviceHandler, tapiContext, connectivityUtils,
-            tapipceListenerImpl, tapirendererListenerImpl);
+            tapipceNotificationHandler, tapirendererNotificationHandler);
 
         ServiceCreateInput createInput = TapiConnectivityDataUtils.buildServiceCreateInput();
         serviceDataStoreOperations.createService(createInput);
index 8efd0441021c50a5f683f7737823d0ac4050355b..9bafd9948d954950680ae5ba7d936f9fd5eee092 100644 (file)
@@ -27,9 +27,9 @@ import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.transportpce.common.network.NetworkTransactionService;
 import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
 import org.opendaylight.transportpce.tapi.impl.TapiProvider;
+import org.opendaylight.transportpce.tapi.listeners.TapiNetworkModelNotificationHandler;
 import org.opendaylight.transportpce.tapi.topology.TapiNetworkModelService;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.OrgOpenroadmServiceService;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.TapiNotificationListener;
 
 @ExtendWith(MockitoExtension.class)
 public class TapiProviderTest {
@@ -49,7 +49,7 @@ public class TapiProviderTest {
     @Mock
     private ServiceDataStoreOperations serviceDataStoreOperations;
     @Mock
-    private TapiNotificationListener tapiNetworkModelListenerImpl;
+    private TapiNetworkModelNotificationHandler tapiNetworkModelNotificationHandler;
     @Mock
     private TapiNetworkModelService tapiNetworkModelServiceImpl;
 
@@ -59,9 +59,9 @@ public class TapiProviderTest {
         doReturn(emptyFluentFuture()).when(networkTransactionService).commit();
         new TapiProvider(dataBroker, rpcProviderRegistry, notificationService, notificationPublishService,
                 networkTransactionService, serviceHandler, serviceDataStoreOperations,
-                tapiNetworkModelListenerImpl, tapiNetworkModelServiceImpl);
+                tapiNetworkModelNotificationHandler, tapiNetworkModelServiceImpl);
 
         verify(rpcProviderRegistry, times(2)).registerRpcImplementations(any());
         verify(dataBroker, times(4)).registerDataTreeChangeListener(any(), any());
     }
-}
\ No newline at end of file
+}