X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fbinding%2Fimpl%2FBindingDOMNotificationServiceAdapter.java;h=2a31d34d016a3e86d116b9c5e9c1f57fb775bd1f;hb=1447e0132075bbd3013aa41b98384a373bd82d1a;hp=6006266cc2d07a2745dca15b6b596415f1a14c9c;hpb=a7e57cf252c2a19a1acfbc23402eed634ae2ac5a;p=controller.git diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationServiceAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationServiceAdapter.java index 6006266cc2..2a31d34d01 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationServiceAdapter.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMNotificationServiceAdapter.java @@ -9,24 +9,15 @@ package org.opendaylight.controller.md.sal.binding.impl; import com.google.common.collect.ClassToInstanceMap; import com.google.common.collect.ImmutableSet; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; import java.util.Set; import org.opendaylight.controller.md.sal.binding.api.NotificationService; import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory; -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.DOMService; -import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder; -import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory; import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer; import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.Notification; import org.opendaylight.yangtools.yang.binding.NotificationListener; -import org.opendaylight.yangtools.yang.binding.util.BindingReflections; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; public class BindingDOMNotificationServiceAdapter implements NotificationService, AutoCloseable { @@ -40,34 +31,20 @@ public class BindingDOMNotificationServiceAdapter implements NotificationService }; private final BindingNormalizedNodeSerializer codec; private final DOMNotificationService domNotifService; - private final NotificationInvokerFactory notificationInvokerFactory; - public BindingDOMNotificationServiceAdapter(final BindingNormalizedNodeSerializer codec, final DOMNotificationService domNotifService, final NotificationInvokerFactory notificationInvokerFactory) { + public BindingDOMNotificationServiceAdapter(final BindingNormalizedNodeSerializer codec, final DOMNotificationService domNotifService) { this.codec = codec; this.domNotifService = domNotifService; - this.notificationInvokerFactory = notificationInvokerFactory; } @Override public ListenerRegistration registerNotificationListener(final T listener) { - final NotificationInvokerFactory.NotificationInvoker invoker = notificationInvokerFactory.invokerFor(listener); - final DOMNotificationListener domListener = new BindingDOMNotificationListenerAdapter(codec, invoker); - final Collection schemaPaths = convertNotifTypesToSchemaPath(invoker.getSupportedNotifications()); - final ListenerRegistration domRegistration = - domNotifService.registerNotificationListener(domListener, schemaPaths); + final BindingDOMNotificationListenerAdapter domListener = new BindingDOMNotificationListenerAdapter(codec, listener); + final ListenerRegistration domRegistration = + domNotifService.registerNotificationListener(domListener, domListener.getSupportedNotifications()); return new ListenerRegistrationImpl<>(listener, domRegistration); } - - - private Collection convertNotifTypesToSchemaPath(final Set> notificationTypes) { - final List schemaPaths = new ArrayList<>(); - for (final Class notificationType : notificationTypes) { - schemaPaths.add(SchemaPath.create(true, BindingReflections.findQName(notificationType))); - } - return schemaPaths; - } - @Override public void close() throws Exception { @@ -89,21 +66,16 @@ public class BindingDOMNotificationServiceAdapter implements NotificationService private static class Builder extends BindingDOMAdapterBuilder { - @Override protected NotificationService createInstance(final BindingToNormalizedNodeCodec codec, final ClassToInstanceMap delegates) { final DOMNotificationService domNotification = delegates.getInstance(DOMNotificationService.class); - final NotificationInvokerFactory invokerFactory = SingletonHolder.INVOKER_FACTORY; - return new BindingDOMNotificationServiceAdapter(codec.getCodecRegistry(), domNotification, invokerFactory); + return new BindingDOMNotificationServiceAdapter(codec.getCodecRegistry(), domNotification); } @Override public Set> getRequiredDelegates() { return ImmutableSet.of(DOMNotificationService.class); } - - - } }