Instead of brewing our own, non-idempotent implementation of
ListenerRegistration use AbstractListenerRegistration which takes
care of being idempotent and holding the listener instance.
Change-Id: I1525f5011c455a0f170d492f164cdeb3b7290b9b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
+import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.slf4j.Logger;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.slf4j.Logger;
listeners.put(type, listener);
}
listeners.put(type, listener);
}
- return new ListenerRegistration<T>() {
+ return new AbstractListenerRegistration<T>(listener) {
+ protected void removeRegistration() {
for (final SchemaPath type : types) {
listeners.remove(type, listener);
}
}
for (final SchemaPath type : types) {
listeners.remove(type, listener);
}
}
-
- @Override
- public T getInstance() {
- return listener;
- }