@Test public void testEventBus() throws Exception { final AtomicInteger counter = new AtomicInteger(0); EventBus<Integer> eventBus = new EventBus<Integer>(null, new EventListener<Integer>() { @Override public void onEvent(Integer event) { counter.set(event); try { Thread.sleep(200); } catch (InterruptedException e) { } } }); eventBus.start(); eventBus.add(1); eventBus.add(2); eventBus.add(3); eventBus.stop(true); Assert.assertEquals(counter.get(), 3); }
public EventBus() { this(null, 0); }
EventBus implements LifeCycle { public EventBus() { this(null, 0); } }
EventBus implements LifeCycle { public EventBus() { this(null, 0); } EventBus();  EventBus(EventListener<E> listener);  EventBus(String name);  EventBus(String name, int capacity);  EventBus(String name, EventListener<E> listener);  EventBus(String name, EventListener<E> listener, int capacity);  EventBus(String name, List<? extends EventListener<E>> listeners); }
EventBus implements LifeCycle { public EventBus() { this(null, 0); } EventBus();  EventBus(EventListener<E> listener);  EventBus(String name);  EventBus(String name, int capacity);  EventBus(String name, EventListener<E> listener);  EventBus(String name, EventListener<E> listener, int capacity);  EventBus(String name, List<? extends EventListener<E>> listeners); long getInterval(); void setInterval(long interval); long getIdleTime(); void setIdleTime(long idleTime); long getTimeout(); void setTimeout(long timeout); void start(); void stop(); void stop(boolean gracefully); boolean isStarted(); boolean addListener(final EventListener<E> listener); boolean removeListener(final EventListener<E> listener); List<EventListener<E>> getListeners(); boolean add(final E event); boolean add(final E event, final long timeout, final TimeUnit unit); boolean add(final E event, final EventListener<E> owner); boolean add(final E event, final EventListener<E> owner, final long timeout, final TimeUnit unit); void inform(final E event); }
EventBus implements LifeCycle { public EventBus() { this(null, 0); } EventBus();  EventBus(EventListener<E> listener);  EventBus(String name);  EventBus(String name, int capacity);  EventBus(String name, EventListener<E> listener);  EventBus(String name, EventListener<E> listener, int capacity);  EventBus(String name, List<? extends EventListener<E>> listeners); long getInterval(); void setInterval(long interval); long getIdleTime(); void setIdleTime(long idleTime); long getTimeout(); void setTimeout(long timeout); void start(); void stop(); void stop(boolean gracefully); boolean isStarted(); boolean addListener(final EventListener<E> listener); boolean removeListener(final EventListener<E> listener); List<EventListener<E>> getListeners(); boolean add(final E event); boolean add(final E event, final long timeout, final TimeUnit unit); boolean add(final E event, final EventListener<E> owner); boolean add(final E event, final EventListener<E> owner, final long timeout, final TimeUnit unit); void inform(final E event);  }