Search in sources :

Example 1 with DOMNotificationListener

use of org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener 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;
}
Also used : AbstractListenerRegistration(org.opendaylight.yangtools.concepts.AbstractListenerRegistration) DOMNotificationListener(org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener) SchemaPath(org.opendaylight.yangtools.yang.model.api.SchemaPath) ListenerRegistration(org.opendaylight.yangtools.concepts.ListenerRegistration) AbstractListenerRegistration(org.opendaylight.yangtools.concepts.AbstractListenerRegistration)

Example 2 with DOMNotificationListener

use of org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener in project controller by opendaylight.

the class DOMNotificationRouterEvent method deliverNotification.

void deliverNotification() {
    LOG.trace("Start delivery of notification {}", notification);
    for (ListenerRegistration<? extends DOMNotificationListener> r : subscribers) {
        final DOMNotificationListener listener = r.getInstance();
        LOG.trace("Notifying listener {}", listener);
        listener.onNotification(notification);
        LOG.trace("Listener notification completed");
    }
    LOG.trace("Delivery completed");
}
Also used : DOMNotificationListener(org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener)

Aggregations

DOMNotificationListener (org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener)2 AbstractListenerRegistration (org.opendaylight.yangtools.concepts.AbstractListenerRegistration)1 ListenerRegistration (org.opendaylight.yangtools.concepts.ListenerRegistration)1 SchemaPath (org.opendaylight.yangtools.yang.model.api.SchemaPath)1