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%2FNotificationBrokerImpl.xtend;h=377d12ecac10340a2e5f64dc4773ae3ed0205e97;hb=a251833f27fd00040904e2df316cd707c8129d1e;hp=8b0400f51254af1a2948f7c72f94bca17e0b292f;hpb=3e5a15bd17299cc88ea253514db40661e11f5bb7;p=controller.git 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 8b0400f512..377d12ecac 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 @@ -14,6 +14,7 @@ import org.opendaylight.controller.sal.binding.api.NotificationListener import com.google.common.collect.HashMultimap import java.util.concurrent.ExecutorService import java.util.Collection +import org.opendaylight.yangtools.concepts.Registration class NotificationBrokerImpl implements NotificationProviderService { @@ -36,9 +37,7 @@ class NotificationBrokerImpl implements NotificationProviderService { } override notify(Notification notification) { - notification.notificationTypes.forEach [ - listeners.get(it as Class)?.notifyAll(notification) - ] + publish(notification) } def getNotificationTypes(Notification notification) { @@ -49,17 +48,65 @@ class NotificationBrokerImpl implements NotificationProviderService { def notifyAll(Collection> listeners, Notification notification) { listeners.forEach[(it as NotificationListener).onNotification(notification)] } - + override addNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) { throw new UnsupportedOperationException("TODO: auto-generated method stub") - + } - + override removeNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) { throw new UnsupportedOperationException("TODO: auto-generated method stub") } - + override notify(Notification notification, ExecutorService service) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") + publish(notification) + } + + override publish(Notification notification) { + notification.notificationTypes.forEach [ + listeners.get(it as Class)?.notifyAll(notification) + ] + } + + override publish(Notification notification, ExecutorService service) { + publish(notification) + } + + override registerNotificationListener(Class notificationType, + NotificationListener listener) { + val reg = new GenericNotificationRegistration(notificationType,listener,this); + listeners.put(notificationType,listener); + return reg; + } + + override registerNotificationListener( + org.opendaylight.yangtools.yang.binding.NotificationListener listener) { + + } + + + protected def unregisterListener(GenericNotificationRegistration reg) { + listeners.remove(reg.type,reg.instance); + } +} +class GenericNotificationRegistration implements Registration> { + + @Property + var NotificationListener instance; + + @Property + val Class type; + + + val NotificationBrokerImpl notificationBroker; + + public new(Class type, NotificationListener instance,NotificationBrokerImpl broker) { + _instance = instance; + _type = type; + notificationBroker = broker; + } + + override close() { + notificationBroker.unregisterListener(this); } }