Пример #1
0
  private void sendMessages() {

    flushCount++;
    lastFlushTime = now;

    stats.recordCount(eventCountStatsKey, messageCountSinceLastFlush);
    messageCountSinceLastFlush = 0;

    if (debug) {
      logger.debug("EventManager {} flushCount {}", name, flushCount);
    }

    final Set<Map.Entry<String, List<Object>>> entries = eventMap.entrySet();
    for (Map.Entry<String, List<Object>> entry : entries) {
      String channelName = entry.getKey();
      final List<Object> events = entry.getValue();
      for (Object event : events) {
        eventBus.send(channelName, event);
      }
      events.clear();
    }

    //noinspection Convert2streamapi
    for (SendQueue<Event<Object>> sendQueue : queuesToFlush) {
      sendQueue.flushSends();
    }
  }
Пример #2
0
  private void invokeEventMethod(Event<Object> event, MethodAccess methodAccess, Object listener) {
    if (event.body() instanceof Object[]) {
      methodAccess.invokeDynamic(listener, (Object[]) event.body());
    } else if (event.body() instanceof List) {
      final List body = (List) event.body();
      methodAccess.invokeDynamic(listener, body.toArray(new Object[body.size()]));

    } else {
      methodAccess.invokeDynamic(listener, event.body());
    }
  }