X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=transportpce.git;a=blobdiff_plain;f=dmaap-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fdmaap%2Fclient%2Flistener%2FNbiNotificationsHandler.java;fp=dmaap-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fdmaap%2Fclient%2Flistener%2FNbiNotificationsListenerImpl.java;h=77f41b4ff271fe697181f162ded3240481d030ee;hp=fcf0b000dd8c80e88ab4c782e025cc2b4af76c93;hb=2261c40a3860d4a2a7be914aac526a6288ec853b;hpb=030d4048d4ab2d7a36f910d5e760a92c5ece76c6 diff --git a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImpl.java b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsHandler.java similarity index 67% rename from dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImpl.java rename to dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsHandler.java index fcf0b000d..77f41b4ff 100644 --- a/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsListenerImpl.java +++ b/dmaap-client/src/main/java/org/opendaylight/transportpce/dmaap/client/listener/NbiNotificationsHandler.java @@ -7,6 +7,7 @@ */ package org.opendaylight.transportpce.dmaap.client.listener; +import java.util.Set; import javax.ws.rs.WebApplicationException; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; @@ -14,22 +15,24 @@ import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; import org.glassfish.jersey.client.proxy.WebResourceFactory; import org.glassfish.jersey.jackson.JacksonFeature; import org.glassfish.jersey.logging.LoggingFeature; +import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener; import org.opendaylight.transportpce.dmaap.client.resource.EventsApi; import org.opendaylight.transportpce.dmaap.client.resource.config.JsonConfigurator; import org.opendaylight.transportpce.dmaap.client.resource.model.CreatedEvent; -import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.NbiNotificationsListener; import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationAlarmService; import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishNotificationProcessService; import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishTapiNotificationService; +import org.opendaylight.yangtools.concepts.Registration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class NbiNotificationsListenerImpl implements NbiNotificationsListener { - private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsListenerImpl.class); +public class NbiNotificationsHandler { + private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsHandler.class); private String topic = "unauthenticated.TPCE"; private EventsApi api; + private Registration reg; - public NbiNotificationsListenerImpl(String baseUrl, String username, String password) { + public NbiNotificationsHandler(String baseUrl, String username, String password) { LOG.info("Dmaap server {} for user {}", baseUrl, username); Client client = ClientBuilder.newClient(); if (username != null && username.isBlank() && password != null && !password.isBlank()) { @@ -43,8 +46,18 @@ public class NbiNotificationsListenerImpl implements NbiNotificationsListener { } - @Override - public void onPublishNotificationProcessService(PublishNotificationProcessService notification) { + public CompositeListener getCompositeListener() { + return new CompositeListener(Set.of( + new CompositeListener.Component<>( + PublishNotificationProcessService.class, this::onPublishNotificationProcessService), + new CompositeListener.Component<>( + PublishNotificationAlarmService.class, this::onPublishNotificationAlarmService), + new CompositeListener.Component<>( + PublishTapiNotificationService.class, this::onPublishTapiNotificationService) + )); + } + + void onPublishNotificationProcessService(PublishNotificationProcessService notification) { try { CreatedEvent response = api.sendEvent(topic, notification); LOG.info("Response received {}", response); @@ -54,11 +67,9 @@ public class NbiNotificationsListenerImpl implements NbiNotificationsListener { } - @Override - public void onPublishNotificationAlarmService(PublishNotificationAlarmService notification) { + private void onPublishNotificationAlarmService(PublishNotificationAlarmService notification) { } - @Override - public void onPublishTapiNotificationService(PublishTapiNotificationService notification) { + private void onPublishTapiNotificationService(PublishTapiNotificationService notification) { } }