import org.opendaylight.yangtools.concepts.Registration\r
import org.opendaylight.yangtools.yang.binding.Notification\r
import org.slf4j.LoggerFactory\r
import org.opendaylight.yangtools.concepts.Registration\r
import org.opendaylight.yangtools.yang.binding.Notification\r
import org.slf4j.LoggerFactory\r
-import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder\r
+import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder\rimport com.google.common.collect.Multimaps\r
+import org.opendaylight.yangtools.concepts.util.ListenerRegistry\r
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService.NotificationInterestListener\r
val Multimap<Class<? extends Notification>, NotificationListener<?>> listeners;\r
\r
@Property\r
var ExecutorService executor;\r
val Multimap<Class<? extends Notification>, NotificationListener<?>> listeners;\r
\r
@Property\r
var ExecutorService executor;\r
NotificationListener<T> listener) {\r
val reg = new GenericNotificationRegistration<T>(notificationType, listener, this);\r
listeners.put(notificationType, listener);\r
NotificationListener<T> listener) {\r
val reg = new GenericNotificationRegistration<T>(notificationType, listener, this);\r
listeners.put(notificationType, listener);\r
+ \r
+ def announceNotificationSubscription(Class<? extends Notification> notification) {\r
+ for (listener : interestListeners) {\r
+ try {\r
+ listener.instance.onNotificationSubscribtion(notification);\r
+ } catch (Exception e) {\r
+ logger.error("", e.message)\r
+ }\r
+ }\r
+ }\r
\r
override registerNotificationListener(\r
org.opendaylight.yangtools.yang.binding.NotificationListener listener) {\r
val invoker = SingletonHolder.INVOKER_FACTORY.invokerFor(listener);\r
for (notifyType : invoker.supportedNotifications) {\r
listeners.put(notifyType, invoker.invocationProxy)\r
\r
override registerNotificationListener(\r
org.opendaylight.yangtools.yang.binding.NotificationListener listener) {\r
val invoker = SingletonHolder.INVOKER_FACTORY.invokerFor(listener);\r
for (notifyType : invoker.supportedNotifications) {\r
listeners.put(notifyType, invoker.invocationProxy)\r
}\r
val registration = new GeneratedListenerRegistration(listener, invoker,this);\r
return registration as Registration<org.opendaylight.yangtools.yang.binding.NotificationListener>;\r
}\r
val registration = new GeneratedListenerRegistration(listener, invoker,this);\r
return registration as Registration<org.opendaylight.yangtools.yang.binding.NotificationListener>;\r
+ override registerInterestListener(NotificationInterestListener interestListener) {\r
+ val registration = interestListeners.register(interestListener);\r
+ \r
+ for(notification : listeners.keySet) {\r
+ interestListener.onNotificationSubscribtion(notification);\r
+ }\r
+ return registration\r
+ }\r
if(log.isDebugEnabled){\r
log.debug("Delivering notification {} to {}",notification,listener);\r
} else {\r
if(log.isDebugEnabled){\r
log.debug("Delivering notification {} to {}",notification,listener);\r
} else {\r
}\r
listener.onNotification(notification);\r
if(log.isDebugEnabled){\r
log.debug("Notification delivered {} to {}",notification,listener);\r
} else {\r
}\r
listener.onNotification(notification);\r
if(log.isDebugEnabled){\r
log.debug("Notification delivered {} to {}",notification,listener);\r
} else {\r
}\r
} catch (Exception e) {\r
log.error("Unhandled exception thrown by listener: {}", listener, e);\r
}\r
} catch (Exception e) {\r
log.error("Unhandled exception thrown by listener: {}", listener, e);\r