+ publish(notification)
+ }
+
+ override publish(Notification notification) {
+ notification.notificationTypes.forEach [
+ listeners.get(it as Class<? extends Notification>)?.notifyAll(notification)
+ ]
+ }
+
+ override publish(Notification notification, ExecutorService service) {
+ publish(notification)
+ }
+
+ override <T extends Notification> registerNotificationListener(Class<T> notificationType,
+ NotificationListener<T> listener) {
+ val reg = new GenericNotificationRegistration<T>(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<T extends Notification> implements Registration<NotificationListener<T>> {
+
+ @Property
+ var NotificationListener<T> instance;
+
+ @Property
+ val Class<T> type;
+
+
+ val NotificationBrokerImpl notificationBroker;
+
+ public new(Class<T> type, NotificationListener<T> instance,NotificationBrokerImpl broker) {
+ _instance = instance;
+ _type = type;
+ notificationBroker = broker;
+ }
+
+ override close() {
+ notificationBroker.unregisterListener(this);