@Override public SubscriberNotificationEvent deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final JsonNode node = p.getCodec().readTree(p); final Class<BusEvent> busEventClass; try { busEventClass = (Class<BusEvent>) Class.forName(node.get("busEventClass").textValue()); } catch (final ClassNotFoundException e) { throw new IOException(e); } return new SubscriberNotificationEvent(objectMapper.treeToValue(node.get("busEvent"), busEventClass), busEventClass); } }
@Override public void handleReadyNotification(final NotificationEvent eventJson, final DateTime eventDateTime, final UUID userToken, final Long searchKey1, final Long searchKey2) { if (!(eventJson instanceof SubscriberNotificationEvent)) { log.error("SubscriberQueueHandler received an unexpected event className='{}'", eventJson.getClass()); } else { final BusEvent busEvent = ((SubscriberNotificationEvent) eventJson).getBusEvent(); final ImmutableSet<Class<?>> eventTypes = FLATTEN_HIERARCHY_CACHE.getUnchecked(busEvent.getClass()); for (final Class<?> eventType : eventTypes) { final SubscriberAction<BusEvent> next = (SubscriberAction<BusEvent>) actions.get(eventType); if (next != null) { next.run(busEvent); } } } } }
public void handleEvent(final BusEvent event) { handleReadyNotification(new SubscriberNotificationEvent(event, event.getClass()), clock.getUTCNow(), event.getUserToken(), event.getSearchKey1(), event.getSearchKey2()); }