@Override public void dispatch(final Object event, final EventSubscriber wrapper) { DefaultEventBus.LOG.trace(DefaultEventBus.DISPATCHING, "Dispatching '{}' to {}", event, wrapper); super.dispatch(event, wrapper); }
public class Aggregator { private EventBus eventBus = new EventBus(); public void register(Object obj) { eventBus.register(obj); } public void dispatch(News news) { eventBus.dispatch(news); } }
/** * Drain the queue of events to be dispatched. As the queue is being drained, * new events may be posted to the end of the queue. */ protected void dispatchQueuedEvents() { // don't dispatch if we're already dispatching, that would allow reentrancy // and out-of-order events. Instead, leave the events to be dispatched // after the in-progress dispatch is complete. if (isDispatching.get()) { return; } isDispatching.set(true); try { while (true) { EventWithHandler eventWithHandler = eventsToDispatch.get().poll(); if (eventWithHandler == null) { break; } dispatch(eventWithHandler.event, eventWithHandler.handler); } } finally { isDispatching.set(false); } }
/** * Drain the queue of events to be dispatched. As the queue is being drained, * new events may be posted to the end of the queue. */ void dispatchQueuedEvents() { // don't dispatch if we're already dispatching, that would allow reentrancy // and out-of-order events. Instead, leave the events to be dispatched // after the in-progress dispatch is complete. if (isDispatching.get()) { return; } isDispatching.set(true); try { Queue<EventWithHandler> events = eventsToDispatch.get(); EventWithHandler eventWithHandler; while ((eventWithHandler = events.poll()) != null) { dispatch(eventWithHandler.event, eventWithHandler.handler); } } finally { isDispatching.remove(); eventsToDispatch.remove(); } }
/** * Drain the queue of events to be dispatched. As the queue is being drained, * new events may be posted to the end of the queue. */ void dispatchQueuedEvents() { // don't dispatch if we're already dispatching, that would allow reentrancy // and out-of-order events. Instead, leave the events to be dispatched // after the in-progress dispatch is complete. if (isDispatching.get()) { return; } isDispatching.set(true); try { Queue<EventWithHandler> events = eventsToDispatch.get(); EventWithHandler eventWithHandler; while ((eventWithHandler = events.poll()) != null) { dispatch(eventWithHandler.event, eventWithHandler.handler); } } finally { isDispatching.remove(); eventsToDispatch.remove(); } }
/** * Drain the queue of events to be dispatched. As the queue is being drained, * new events may be posted to the end of the queue. */ void dispatchQueuedEvents() { // don't dispatch if we're already dispatching, that would allow reentrancy // and out-of-order events. Instead, leave the events to be dispatched // after the in-progress dispatch is complete. if (isDispatching.get()) { return; } isDispatching.set(true); try { Queue<EventWithHandler> events = eventsToDispatch.get(); EventWithHandler eventWithHandler; while ((eventWithHandler = events.poll()) != null) { dispatch(eventWithHandler.event, eventWithHandler.handler); } } finally { isDispatching.remove(); eventsToDispatch.remove(); } }
/** * Drain the queue of events to be dispatched. As the queue is being drained, * new events may be posted to the end of the queue. */ void dispatchQueuedEvents() { // don't dispatch if we're already dispatching, that would allow reentrancy // and out-of-order events. Instead, leave the events to be dispatched // after the in-progress dispatch is complete. if (isDispatching.get()) { return; } isDispatching.set(true); try { Queue<EventWithHandler> events = eventsToDispatch.get(); EventWithHandler eventWithHandler; while ((eventWithHandler = events.poll()) != null) { dispatch(eventWithHandler.event, eventWithHandler.handler); } } finally { isDispatching.remove(); eventsToDispatch.remove(); } }
/** * Drain the queue of events to be dispatched. As the queue is being drained, * new events may be posted to the end of the queue. */ void dispatchQueuedEvents() { // don't dispatch if we're already dispatching, that would allow reentrancy // and out-of-order events. Instead, leave the events to be dispatched // after the in-progress dispatch is complete. if (isDispatching.get()) { return; } isDispatching.set(true); try { Queue<EventWithSubscriber> events = eventsToDispatch.get(); EventWithSubscriber eventWithSubscriber; while ((eventWithSubscriber = events.poll()) != null) { dispatch(eventWithSubscriber.event, eventWithSubscriber.subscriber); } } finally { isDispatching.remove(); eventsToDispatch.remove(); } }
/** * Drain the queue of events to be dispatched. As the queue is being drained, * new events may be posted to the end of the queue. */ void dispatchQueuedEvents() { // don't dispatch if we're already dispatching, that would allow reentrancy // and out-of-order events. Instead, leave the events to be dispatched // after the in-progress dispatch is complete. if (isDispatching.get()) { return; } isDispatching.set(true); try { Queue<EventWithHandler> events = eventsToDispatch.get(); EventWithHandler eventWithHandler; while ((eventWithHandler = events.poll()) != null) { dispatch(eventWithHandler.event, eventWithHandler.handler); } } finally { isDispatching.remove(); eventsToDispatch.remove(); } }
/** * Drain the queue of events to be dispatched. As the queue is being drained, * new events may be posted to the end of the queue. */ void dispatchQueuedEvents() { // don't dispatch if we're already dispatching, that would allow reentrancy // and out-of-order events. Instead, leave the events to be dispatched // after the in-progress dispatch is complete. if (isDispatching.get()) { return; } isDispatching.set(true); try { Queue<EventWithSubscriber> events = eventsToDispatch.get(); EventWithSubscriber eventWithSubscriber; while ((eventWithSubscriber = events.poll()) != null) { dispatch(eventWithSubscriber.event, eventWithSubscriber.subscriber); } } finally { isDispatching.remove(); eventsToDispatch.remove(); } }