private <H> void doFire(RemoteEvent<H> event, int uuid) { if (event == null) { throw new NullPointerException("Cannot fire null event"); } try { firingDepth++; if (uuid != 0) { setSourceUuidOfEvent(event, uuid); } setEventBusUuidOfEvent(event, getUUID()); List<H> handlers = getDispatchList(event.getAssociatedType(), uuid); Set<Throwable> causes = null; ListIterator<H> it = handlers.listIterator(); while (it.hasNext()) { H handler = it.next(); try { dispatchEvent(event, handler); } catch (Throwable e) { if (causes == null) { causes = new HashSet<Throwable>(); } causes.add(e); } } if (causes != null) { throw new UmbrellaException(causes); } } finally { firingDepth--; if (firingDepth == 0) { handleQueuedAddsAndRemoves(); } } }
protected static void setEventBusUuidOfEvent(RemoteEvent<?> event, long eventBusUUID) { event.setEventBusUUID(eventBusUUID); }
protected static void setSourceUuidOfEvent(RemoteEvent<?> event, int uuid) { event.setSourceUUID(uuid); }
protected static <H> void dispatchEvent(RemoteEvent<H> event, H handler) { event.dispatch(handler); }