use of org.opendaylight.yangtools.yang.binding.NotificationListener in project controller by opendaylight.
the class BindingDOMNotificationListenerAdapter method createInvokerMapFor.
public static Map<SchemaPath, NotificationListenerInvoker> createInvokerMapFor(final Class<? extends NotificationListener> implClz) {
final Map<SchemaPath, NotificationListenerInvoker> builder = new HashMap<>();
for (final TypeToken<?> ifaceToken : TypeToken.of(implClz).getTypes().interfaces()) {
Class<?> iface = ifaceToken.getRawType();
if (NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
@SuppressWarnings("unchecked") final Class<? extends NotificationListener> listenerType = (Class<? extends NotificationListener>) iface;
final NotificationListenerInvoker invoker = NotificationListenerInvoker.from(listenerType);
for (final SchemaPath path : getNotificationTypes(listenerType)) {
builder.put(path, invoker);
}
}
}
return ImmutableMap.copyOf(builder);
}
use of org.opendaylight.yangtools.yang.binding.NotificationListener in project controller by opendaylight.
the class BackwardsCompatibleNotificationBrokerTest method testNotifSubscriptionForwarded.
@Test
public void testNotifSubscriptionForwarded() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final TwoLevelListChanged testData = createTestData();
final NotifTestListenerChild testNotifListener = new NotifTestListenerChild(latch);
final ListenerRegistration<NotificationListener> listenerRegistration = notificationProviderService.registerNotificationListener(testNotifListener);
notificationProviderService.publish(testData);
latch.await(500L, TimeUnit.MILLISECONDS);
assertTrue(testNotifListener.getReceivedNotifications().size() == 1);
assertEquals(testData, testNotifListener.getReceivedNotifications().get(0));
listenerRegistration.close();
}
Aggregations