package org.opendaylight.controller.md.sal.binding.impl;
import com.google.common.collect.ImmutableMap;
package org.opendaylight.controller.md.sal.binding.impl;
import com.google.common.collect.ImmutableMap;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
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.DOMNotification;
import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
-import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.mdsal.binding.dom.adapter.invoke.NotificationListenerInvoker;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+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.Notification;
import org.opendaylight.yangtools.yang.binding.NotificationListener;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
private final NotificationListener delegate;
private final Map<SchemaPath,NotificationListenerInvoker> invokers;
private final NotificationListener delegate;
private final Map<SchemaPath,NotificationListenerInvoker> invokers;
- public BindingDOMNotificationListenerAdapter(final BindingNormalizedNodeSerializer codec, final NotificationListener delegate) {
+ BindingDOMNotificationListenerAdapter(final BindingNormalizedNodeSerializer codec,
+ final NotificationListener delegate) {
final Notification baNotification = deserialize(notification);
final QName notificationQName = notification.getType().getLastComponent();
getInvoker(notification.getType()).invokeNotification(delegate, notificationQName, baNotification);
}
private Notification deserialize(final DOMNotification notification) {
final Notification baNotification = deserialize(notification);
final QName notificationQName = notification.getType().getLastComponent();
getInvoker(notification.getType()).invokeNotification(delegate, notificationQName, baNotification);
}
private Notification deserialize(final DOMNotification notification) {
return ((LazySerializedDOMNotification) notification).getBindingData();
}
return codec.fromNormalizedNodeNotification(notification.getType(), notification.getBody());
return ((LazySerializedDOMNotification) notification).getBindingData();
}
return codec.fromNormalizedNodeNotification(notification.getType(), notification.getBody());
- public static Map<SchemaPath, NotificationListenerInvoker> createInvokerMapFor(final Class<? extends NotificationListener> implClz) {
+ public static Map<SchemaPath, NotificationListenerInvoker> createInvokerMapFor(
+ final Class<? extends NotificationListener> implClz) {
- for(final Class<?> iface : implClz.getInterfaces()) {
- if(NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
+ for (final TypeToken<?> ifaceToken : TypeToken.of(implClz).getTypes().interfaces()) {
+ Class<?> iface = ifaceToken.getRawType();
+ if (NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
// TODO: Investigate possibility and performance impact if we cache this or expose
// it from NotificationListenerInvoker
final Set<SchemaPath> ret = new HashSet<>();
// TODO: Investigate possibility and performance impact if we cache this or expose
// it from NotificationListenerInvoker
final Set<SchemaPath> ret = new HashSet<>();
- for(final Method method : type.getMethods()) {
- if(BindingReflections.isNotificationCallback(method)) {
+ for (final Method method : type.getMethods()) {
+ if (BindingReflections.isNotificationCallback(method)) {
final Class<?> notification = method.getParameterTypes()[0];
final QName name = BindingReflections.findQName(notification);
ret.add(SchemaPath.create(true, name));
final Class<?> notification = method.getParameterTypes()[0];
final QName name = BindingReflections.findQName(notification);
ret.add(SchemaPath.create(true, name));