import org.slf4j.LoggerFactory
import java.util.concurrent.Callable
-class NotificationBrokerImpl implements NotificationProviderService {
+class NotificationBrokerImpl implements NotificationProviderService, AutoCloseable {
val Multimap<Class<? extends Notification>, NotificationListener<?>> listeners;
@Property
var ExecutorService executor;
- @Property
- var RuntimeCodeGenerator generator;
-
- @Property
- var NotificationInvokerFactory invokerFactory;
-
new(ExecutorService executor) {
listeners = HashMultimap.create()
this.executor = executor;
override registerNotificationListener(
org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
- val invoker = invokerFactory.invokerFor(listener);
+ val invoker = BindingAwareBrokerImpl.generator.invokerFactory.invokerFor(listener);
for (notifyType : invoker.supportedNotifications) {
listeners.put(notifyType, invoker.invocationProxy)
}
listeners.remove(notifyType, reg.invoker.invocationProxy)
}
}
+
+ override close() {
+ //FIXME: implement properly.
+ }
+
}
class GenericNotificationRegistration<T extends Notification> extends AbstractObjectRegistration<NotificationListener<T>> implements ListenerRegistration<NotificationListener<T>> {
override call() {
try {
+ log.info("Delivering notification {} to {}",notification,listener);
listener.onNotification(notification);
+ log.info("Notification delivered {} to {}",notification,listener);
} catch (Exception e) {
log.error("Unhandled exception thrown by listener: {}", listener, e);
}