X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Fimpl%2FNotifyTask.java;h=2622a71e55200c0a3ca2fafac2ad3a3c0f324ad0;hb=19d6071f01bbf7a7c74f4a79890540144970c010;hp=b0dd2a90f7b8d53a1a4c4432d0d7074a1438ff4e;hpb=5bd4e3c091c2d309243b258eb014014db284f025;p=controller.git diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotifyTask.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotifyTask.java index b0dd2a90f7..2622a71e55 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotifyTask.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotifyTask.java @@ -7,9 +7,6 @@ */ package org.opendaylight.controller.sal.binding.impl; -import java.util.concurrent.Callable; - -import org.opendaylight.controller.sal.binding.api.NotificationListener; import org.opendaylight.yangtools.yang.binding.Notification; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -17,50 +14,48 @@ import org.slf4j.LoggerFactory; import com.google.common.base.Objects; import com.google.common.base.Preconditions; -class NotifyTask implements Callable { +class NotifyTask implements Runnable { private static final Logger LOG = LoggerFactory.getLogger(NotifyTask.class); - private final NotificationListener listener; + private final NotificationListenerRegistration registration; private final Notification notification; - public NotifyTask(final NotificationListener listener, final Notification notification) { - this.listener = Preconditions.checkNotNull(listener); + public NotifyTask(final NotificationListenerRegistration registration, final Notification notification) { + this.registration = Preconditions.checkNotNull(registration); this.notification = Preconditions.checkNotNull(notification); } @SuppressWarnings("unchecked") - private NotificationListener getListener() { - return (NotificationListener)listener; + private NotificationListenerRegistration getRegistration() { + return (NotificationListenerRegistration)registration; } @Override - public Object call() { + public void run() { if (LOG.isDebugEnabled()) { - LOG.debug("Delivering notification {} to {}", notification, listener); + LOG.debug("Delivering notification {} to {}", notification, registration.getInstance()); } else { - LOG.trace("Delivering notification {} to {}", notification.getClass().getName(), listener); + LOG.trace("Delivering notification {} to {}", notification.getClass().getName(), registration.getInstance()); } try { - getListener().onNotification(notification); + getRegistration().notify(notification); } catch (final Exception e) { - LOG.error("Unhandled exception thrown by listener: {}", listener, e); + LOG.error("Unhandled exception thrown by listener: {}", registration.getInstance(), e); } if (LOG.isDebugEnabled()) { - LOG.debug("Notification delivered {} to {}", notification, listener); + LOG.debug("Notification delivered {} to {}", notification, registration.getInstance()); } else { - LOG.trace("Notification delivered {} to {}", notification.getClass().getName(), listener); + LOG.trace("Notification delivered {} to {}", notification.getClass().getName(), registration.getInstance()); } - - return null; } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((listener== null) ? 0 : listener.hashCode()); + result = prime * result + ((registration== null) ? 0 : registration.hashCode()); result = prime * result + ((notification== null) ? 0 : notification.hashCode()); return result; } @@ -74,10 +69,10 @@ class NotifyTask implements Callable { if (getClass() != obj.getClass()) return false; NotifyTask other = (NotifyTask) obj; - if (listener == null) { - if (other.listener != null) + if (registration == null) { + if (other.registration != null) return false; - } else if (!listener.equals(other.listener)) + } else if (!registration.equals(other.registration)) return false; if (notification == null) { if (other.notification != null) @@ -90,7 +85,7 @@ class NotifyTask implements Callable { @Override public String toString() { return Objects.toStringHelper(this) - .add("listener", listener) + .add("listener", registration) .add("notification", notification.getClass()) .toString(); }