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%2Fsal%2Fbinding%2Fimpl%2FNotificationBrokerImpl.xtend;h=6d675b4b5eb5f546b1a7fd7743d301fb62a56f0b;hp=a7dcf80e8dbd5366ca366b0d2c50fce573a598bf;hb=b66923141fce710094cb8e61bf794f9f0e678f50;hpb=a8c8aaec133a4f8d2b747bd4a798481657040320 diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.xtend index a7dcf80e8d..6d675b4b5e 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.xtend +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.xtend @@ -8,25 +8,26 @@ package org.opendaylight.controller.sal.binding.impl import com.google.common.collect.HashMultimap +import com.google.common.collect.ImmutableSet import com.google.common.collect.Multimap -import java.util.Collection +import com.google.common.collect.Multimaps import java.util.Collections import java.util.concurrent.Callable import java.util.concurrent.ExecutorService +import java.util.concurrent.Future +import java.util.Set import org.opendaylight.controller.sal.binding.api.NotificationListener import org.opendaylight.controller.sal.binding.api.NotificationProviderService +import org.opendaylight.controller.sal.binding.api.NotificationProviderService.NotificationInterestListener +import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory.NotificationInvoker import org.opendaylight.yangtools.concepts.AbstractObjectRegistration import org.opendaylight.yangtools.concepts.ListenerRegistration import org.opendaylight.yangtools.concepts.Registration +import org.opendaylight.yangtools.concepts.util.ListenerRegistry import org.opendaylight.yangtools.yang.binding.Notification import org.slf4j.LoggerFactory -import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder import com.google.common.collect.Multimaps -import org.opendaylight.yangtools.concepts.util.ListenerRegistry -import org.opendaylight.controller.sal.binding.api.NotificationProviderService.NotificationInterestListener import java.util.Set -import com.google.common.collect.ImmutableSet -import java.util.concurrent.Future - + class NotificationBrokerImpl implements NotificationProviderService, AutoCloseable { val ListenerRegistry interestListeners = ListenerRegistry.create; @@ -48,48 +49,10 @@ class NotificationBrokerImpl implements NotificationProviderService, AutoCloseab this.executor = executor; } - @Deprecated - override addNotificationListener(Class notificationType, - NotificationListener listener) { - listeners.put(notificationType, listener) - } - - @Deprecated - override removeNotificationListener(Class notificationType, - NotificationListener listener) { - listeners.remove(notificationType, listener) - } - - override notify(Notification notification) { - publish(notification) - } - def getNotificationTypes(Notification notification) { notification.class.interfaces.filter[it != Notification && Notification.isAssignableFrom(it)] } - @SuppressWarnings("unchecked") - private def notifyAll(Collection> listeners, Notification notification) { - listeners.forEach[(it as NotificationListener).onNotification(notification)] - } - - @Deprecated - override addNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) { - throw new UnsupportedOperationException("Deprecated method. Use registerNotificationListener instead."); - - } - - @Deprecated - override removeNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) { - throw new UnsupportedOperationException( - "Deprecated method. Use RegisterNotificationListener returned value to close registration.") - } - - @Deprecated - override notify(Notification notification, ExecutorService service) { - publish(notification, service) - } - override publish(Notification notification) { publish(notification, executor) } @@ -97,7 +60,7 @@ class NotificationBrokerImpl implements NotificationProviderService, AutoCloseab override publish(Notification notification, ExecutorService service) { val allTypes = notification.notificationTypes - var Iterable> listenerToNotify = Collections.emptySet(); + var Iterable> listenerToNotify = Collections.emptySet(); for (type : allTypes) { listenerToNotify = listenerToNotify + listeners.get(type as Class) } @@ -105,14 +68,14 @@ class NotificationBrokerImpl implements NotificationProviderService, AutoCloseab submitAll(executor,tasks); } - def submitAll(ExecutorService service, Set tasks) { + def submitAll(ExecutorService service, Set tasks) { val ret = ImmutableSet.>builder(); for(task : tasks) { ret.add(service.submit(task)); } - return ret.build(); + return ret.build(); } - + override registerNotificationListener(Class notificationType, NotificationListener listener) { val reg = new GenericNotificationRegistration(notificationType, listener, this);