X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fbinding%2Fcompat%2FNotificationInvoker.java;h=6f60ef44f045451e37395a3df014f284b5278d31;hp=cdc6315e4930c7433f11e3fe8de3e3c7efea100a;hb=2a6aa1775604906755883f810ee9ea6d5f286135;hpb=2727bea09c83646b6cbd2ef9672d0b7f6cf3b22f diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/NotificationInvoker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/NotificationInvoker.java index cdc6315e49..6f60ef44f0 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/NotificationInvoker.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/NotificationInvoker.java @@ -14,13 +14,15 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import org.opendaylight.mdsal.binding.dom.adapter.invoke.NotificationListenerInvoker; +import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; 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.binding.util.NotificationListenerInvoker; import org.opendaylight.yangtools.yang.common.QName; -final class NotificationInvoker implements org.opendaylight.controller.sal.binding.api.NotificationListener { +@Deprecated(forRemoval = true) +final class NotificationInvoker + implements org.opendaylight.controller.sal.binding.api.NotificationListener { private final NotificationListener delegate; private final Map,InvokerContext> invokers; @@ -29,14 +31,15 @@ final class NotificationInvoker implements org.opendaylight.controller.sal.bindi private NotificationInvoker(final NotificationListener listener) { delegate = listener; final Map, InvokerContext> builder = new HashMap<>(); - for(final TypeToken ifaceToken : TypeToken.of(listener.getClass()).getTypes().interfaces()) { - Class iface = ifaceToken.getRawType(); - if(NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) { + for (final TypeToken ifaceToken : TypeToken.of(listener.getClass()).getTypes().interfaces()) { + final Class iface = ifaceToken.getRawType(); + if (NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) { @SuppressWarnings("unchecked") - final Class listenerType = (Class) iface; + final Class listenerType = + (Class) iface; final NotificationListenerInvoker invoker = NotificationListenerInvoker.from(listenerType); - for(final Class type : getNotificationTypes(listenerType)) { - builder.put(type, new InvokerContext(BindingReflections.findQName(type) , invoker)); + for (final Class type : getNotificationTypes(listenerType)) { + builder.put(type, new InvokerContext(BindingReflections.findQName(type), invoker)); } } } @@ -53,28 +56,30 @@ final class NotificationInvoker implements org.opendaylight.controller.sal.bindi @Override public void onNotification(final Notification notification) { - getContext(notification.getImplementedInterface()).invoke(notification); - }; + getContext(notification.implementedInterface()).invoke(notification); + } private InvokerContext getContext(final Class type) { return invokers.get(type); } @SuppressWarnings("unchecked") - private static Set> getNotificationTypes(final Class type) { + private static Set> getNotificationTypes( + final Class type) { // TODO: Investigate possibility and performance impact if we cache this or expose // it from NotificationListenerInvoker final Set> ret = new HashSet<>(); - for(final Method method : type.getMethods()) { - if(BindingReflections.isNotificationCallback(method)) { - final Class notification = (Class) method.getParameterTypes()[0]; + for (final Method method : type.getMethods()) { + if (BindingReflections.isNotificationCallback(method)) { + final Class notification = + (Class) method.getParameterTypes()[0]; ret.add(notification); } } return ret; } - private class InvokerContext { + private final class InvokerContext { private final QName name; private final NotificationListenerInvoker invoker; @@ -87,7 +92,5 @@ final class NotificationInvoker implements org.opendaylight.controller.sal.bindi public void invoke(final Notification notification) { invoker.invokeNotification(delegate, name, notification); } - } - }