use of org.opendaylight.yangtools.concepts.AbstractListenerRegistration in project controller by opendaylight.
the class HeliumNotificationProviderServiceWithInterestListeners method registerNotificationListener.
@Override
public <T extends Notification> ListenerRegistration<NotificationListener<T>> registerNotificationListener(final Class<T> type, final NotificationListener<T> listener) {
final FunctionalNotificationListenerAdapter<T> adapter = new FunctionalNotificationListenerAdapter<>(codec, type, listener);
final SchemaPath domType = SchemaPath.create(true, BindingReflections.findQName(type));
final ListenerRegistration<?> domReg = domService.registerNotificationListener(adapter, domType);
return new AbstractListenerRegistration<NotificationListener<T>>(listener) {
@Override
protected void removeRegistration() {
domReg.close();
}
};
}
use of org.opendaylight.yangtools.concepts.AbstractListenerRegistration in project controller by opendaylight.
the class DOMNotificationRouter method registerNotificationListener.
@Override
public synchronized <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener, final Collection<SchemaPath> types) {
final ListenerRegistration<T> reg = new AbstractListenerRegistration<T>(listener) {
@Override
protected void removeRegistration() {
final ListenerRegistration<T> me = this;
synchronized (DOMNotificationRouter.this) {
replaceListeners(ImmutableMultimap.copyOf(Multimaps.filterValues(listeners, input -> input != me)));
}
}
};
if (!types.isEmpty()) {
final Builder<SchemaPath, ListenerRegistration<? extends DOMNotificationListener>> b = ImmutableMultimap.builder();
b.putAll(listeners);
for (final SchemaPath t : types) {
b.put(t, reg);
}
replaceListeners(b.build());
}
return reg;
}
Aggregations