X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fbinding%2Fcompat%2FHeliumNotificationProviderServiceWithInterestListeners.java;h=4dd35211cef1db296f537e0504bc6c9f72eaeecb;hp=1eb421de7c7ef249a363cfd567eb1b4d4a4bc6df;hb=079163ec73e4304ebe9b6f9076f78e22e2d0e3a5;hpb=954e4ad11529b9704d55e51abf33df4e40d5fb82 diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceWithInterestListeners.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceWithInterestListeners.java index 1eb421de7c..4dd35211ce 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceWithInterestListeners.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HeliumNotificationProviderServiceWithInterestListeners.java @@ -18,18 +18,19 @@ import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService; import org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListener; import org.opendaylight.controller.md.sal.dom.spi.DOMNotificationSubscriptionListenerRegistry; import org.opendaylight.controller.sal.binding.api.NotificationListener; +import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.util.ListenerRegistry; import org.opendaylight.yangtools.yang.binding.Notification; -import org.opendaylight.yangtools.yang.binding.util.BindingReflections; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class HeliumNotificationProviderServiceWithInterestListeners extends HeliumNotificationProviderServiceAdapter { - private static final Logger LOG = LoggerFactory.getLogger(HeliumNotificationProviderServiceWithInterestListeners.class); + private static final Logger LOG = LoggerFactory.getLogger( + HeliumNotificationProviderServiceWithInterestListeners.class); private final ListenerRegistry interestListeners = ListenerRegistry.create(); private final ListenerRegistration domListener; @@ -37,7 +38,9 @@ public class HeliumNotificationProviderServiceWithInterestListeners extends Heli private final BindingToNormalizedNodeCodec codec; public HeliumNotificationProviderServiceWithInterestListeners( - final BindingDOMNotificationPublishServiceAdapter publishService, final BindingDOMNotificationServiceAdapter listenService, final DOMNotificationSubscriptionListenerRegistry registry) { + final BindingDOMNotificationPublishServiceAdapter publishService, + final BindingDOMNotificationServiceAdapter listenService, + final DOMNotificationSubscriptionListenerRegistry registry) { super(publishService, listenService); this.codec = publishService.getCodecRegistry(); this.domListener = registry.registerSubscriptionListener(new Listener()); @@ -55,16 +58,18 @@ public class HeliumNotificationProviderServiceWithInterestListeners extends Heli return codec.getNotificationClasses(added); } + @SuppressWarnings("checkstyle:IllegalCatch") private void notifyAllListeners(final Set added) { - final Iterator> listeners = interestListeners.iterator(); - if(listeners.hasNext()) { + final Iterator> listeners = + interestListeners.getRegistrations().iterator(); + if (listeners.hasNext()) { final Set> baEvent = translate(added); - while(listeners.hasNext()) { + while (listeners.hasNext()) { final NotificationInterestListener listenerRef = listeners.next().getInstance(); try { - notifyListener(listenerRef,baEvent); - } catch (final Exception e) { - LOG.warn("Unhandled exception during invoking listener {}",e, listenerRef); + notifyListener(listenerRef, baEvent); + } catch (RuntimeException e) { + LOG.warn("Unhandled exception during invoking listener {}", listenerRef, e); } } } @@ -74,7 +79,8 @@ public class HeliumNotificationProviderServiceWithInterestListeners extends Heli public ListenerRegistration> registerNotificationListener( final Class type, final NotificationListener listener) { - final FunctionalNotificationListenerAdapter adapter = new FunctionalNotificationListenerAdapter<>(codec, type, listener); + final FunctionalNotificationListenerAdapter adapter = + new FunctionalNotificationListenerAdapter<>(codec, type, listener); final SchemaPath domType = SchemaPath.create(true, BindingReflections.findQName(type)); final ListenerRegistration domReg = domService.registerNotificationListener(adapter, domType); return new AbstractListenerRegistration>(listener) { @@ -82,12 +88,12 @@ public class HeliumNotificationProviderServiceWithInterestListeners extends Heli protected void removeRegistration() { domReg.close(); } - }; } - private void notifyListener(final NotificationInterestListener listener, final Set> baEvent) { - for(final Class event: baEvent) { + private static void notifyListener(final NotificationInterestListener listener, + final Set> baEvent) { + for (final Class event: baEvent) { listener.onNotificationSubscribtion(event); } } @@ -109,7 +115,7 @@ public class HeliumNotificationProviderServiceWithInterestListeners extends Heli } @Override - public void close() throws Exception { + public void close() { super.close(); domListener.close(); }