use of org.opendaylight.yangtools.yang.binding.Notification in project bgpcep by opendaylight.
the class RouteMonitoringMessageHandler method parseMessageBody.
@Override
public Notification parseMessageBody(final ByteBuf bytes) throws BmpDeserializationException {
final RouteMonitoringMessageBuilder routeMonitor = new RouteMonitoringMessageBuilder().setPeerHeader(parsePerPeerHeader(bytes));
try {
final Notification message = this.msgRegistry.parseMessage(bytes, null);
requireNonNull(message, "UpdateMessage may not be null");
Preconditions.checkArgument(message instanceof UpdateMessage, "An instance of UpdateMessage is required");
final UpdateMessage updateMessage = (UpdateMessage) message;
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.route.monitoring.message.Update update = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.route.monitoring.message.UpdateBuilder(updateMessage).build();
routeMonitor.setUpdate(update);
} catch (final BGPDocumentedException | BGPParsingException e) {
throw new BmpDeserializationException("Error while parsing Update Message.", e);
}
return routeMonitor.build();
}
use of org.opendaylight.yangtools.yang.binding.Notification in project bgpcep by opendaylight.
the class AbstractBmpPerPeerMessageParserTest method setUp.
@Before
public void setUp() {
this.ctx = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance();
final MessageRegistry msgRegistry = this.ctx.getMessageRegistry();
this.parser = new AbstractBmpPerPeerMessageParser<Builder<?>>(msgRegistry) {
@Override
public Notification parseMessageBody(final ByteBuf bytes) {
return null;
}
@Override
public int getBmpMessageType() {
return 0;
}
};
}
use of org.opendaylight.yangtools.yang.binding.Notification in project controller by opendaylight.
the class BindingToNormalizedNodeCodec method getNotificationClasses.
@SuppressWarnings("unchecked")
public Set<Class<? extends Notification>> getNotificationClasses(final Set<SchemaPath> interested) {
final Set<Class<? extends Notification>> result = new HashSet<>();
final Set<NotificationDefinition> knownNotifications = runtimeContext().getSchemaContext().getNotifications();
for (final NotificationDefinition notification : knownNotifications) {
if (interested.contains(notification.getPath())) {
try {
result.add((Class<? extends Notification>) runtimeContext().getClassForSchema(notification));
} catch (final IllegalStateException e) {
// Ignore
LOG.warn("Class for {} is currently not known.", notification.getPath(), e);
}
}
}
return result;
}
use of org.opendaylight.yangtools.yang.binding.Notification in project controller by opendaylight.
the class BindingDOMNotificationListenerAdapter method onNotification.
@Override
public void onNotification(@Nonnull final DOMNotification notification) {
final Notification baNotification = deserialize(notification);
final QName notificationQName = notification.getType().getLastComponent();
getInvoker(notification.getType()).invokeNotification(delegate, notificationQName, baNotification);
}
use of org.opendaylight.yangtools.yang.binding.Notification in project controller by opendaylight.
the class NotificationInvoker method getNotificationTypes.
@SuppressWarnings("unchecked")
private static Set<Class<? extends Notification>> getNotificationTypes(final Class<? extends org.opendaylight.yangtools.yang.binding.NotificationListener> type) {
// TODO: Investigate possibility and performance impact if we cache this or expose
// it from NotificationListenerInvoker
final Set<Class<? extends Notification>> ret = new HashSet<>();
for (final Method method : type.getMethods()) {
if (BindingReflections.isNotificationCallback(method)) {
final Class<? extends Notification> notification = (Class<? extends Notification>) method.getParameterTypes()[0];
ret.add(notification);
}
}
return ret;
}
Aggregations