@Test(timeout = 60000) public void testInvokeListeners() throws Exception { final MockEventListener listener = new MockEventListener(); holderRule.getHolder().subscribe(listener); holderRule.assertListenerAdded(listener); holderRule.getHolder().invokeListeners(new Action1<MockEventListener>() { @Override public void call(MockEventListener mockEventListener) { mockEventListener.anEvent(); } }); assertThat("Listener not invoked.", listener.getEventInvocationCount(), is(1)); }
public void invokeListeners(Action1<T> invocationAction) { ListenerInvocationException exception = null; for (final ListenerHolder<T> listener : listeners) { if (!listener.subscription.isUnsubscribed()) { try { invocationAction.call(listener.delegate); } catch (Throwable e) { exception = handleListenerError(exception, listener, e); } } } if (null != exception) { exception.finish(); logger.error("Error occured while invoking event listeners.", exception); } }
ListenersHolder implements EventSource<T>, EventPublisher { public void invokeListeners(Action1<T> invocationAction) { ListenerInvocationException exception = null; for (final ListenerHolder<T> listener : listeners) { if (!listener.subscription.isUnsubscribed()) { try { invocationAction.call(listener.delegate); } catch (Throwable e) { exception = handleListenerError(exception, listener, e); } } } if (null != exception) { exception.finish(); logger.error("Error occured while invoking event listeners.", exception); } } }
ListenersHolder implements EventSource<T>, EventPublisher { public void invokeListeners(Action1<T> invocationAction) { ListenerInvocationException exception = null; for (final ListenerHolder<T> listener : listeners) { if (!listener.subscription.isUnsubscribed()) { try { invocationAction.call(listener.delegate); } catch (Throwable e) { exception = handleListenerError(exception, listener, e); } } } if (null != exception) { exception.finish(); logger.error("Error occured while invoking event listeners.", exception); } } ListenersHolder();  ListenersHolder(ListenersHolder<T> toCopy); }
ListenersHolder implements EventSource<T>, EventPublisher { public void invokeListeners(Action1<T> invocationAction) { ListenerInvocationException exception = null; for (final ListenerHolder<T> listener : listeners) { if (!listener.subscription.isUnsubscribed()) { try { invocationAction.call(listener.delegate); } catch (Throwable e) { exception = handleListenerError(exception, listener, e); } } } if (null != exception) { exception.finish(); logger.error("Error occured while invoking event listeners.", exception); } } ListenersHolder();  ListenersHolder(ListenersHolder<T> toCopy); @Override Subscription subscribe(final T listener); @Override boolean publishingEnabled(); void dispose(); void invokeListeners(Action1<T> invocationAction); void invokeListeners(Action3<T, Long, TimeUnit> invocationAction, long duration, TimeUnit timeUnit); void invokeListeners(Action4<T, Long, TimeUnit, Throwable> invocationAction, long duration,
                                TimeUnit timeUnit, Throwable throwable); void invokeListeners(Action4<T, Long, TimeUnit, A> invocationAction, long duration,
                                    TimeUnit timeUnit, A arg); void invokeListeners(Action5<T, Long, TimeUnit, Throwable, A> invocationAction, long duration,
                                    TimeUnit timeUnit, Throwable throwable, A arg); void invokeListeners(Action2<T, A> invocationAction, A arg); void invokeListeners(Action3<T, Throwable, A> invocationAction, Throwable throwable, A arg); ListenersHolder<T> copy(); void subscribeAllTo(EventSource<T> lazySource); }
ListenersHolder implements EventSource<T>, EventPublisher { public void invokeListeners(Action1<T> invocationAction) { ListenerInvocationException exception = null; for (final ListenerHolder<T> listener : listeners) { if (!listener.subscription.isUnsubscribed()) { try { invocationAction.call(listener.delegate); } catch (Throwable e) { exception = handleListenerError(exception, listener, e); } } } if (null != exception) { exception.finish(); logger.error("Error occured while invoking event listeners.", exception); } } ListenersHolder();  ListenersHolder(ListenersHolder<T> toCopy); @Override Subscription subscribe(final T listener); @Override boolean publishingEnabled(); void dispose(); void invokeListeners(Action1<T> invocationAction); void invokeListeners(Action3<T, Long, TimeUnit> invocationAction, long duration, TimeUnit timeUnit); void invokeListeners(Action4<T, Long, TimeUnit, Throwable> invocationAction, long duration,
                                TimeUnit timeUnit, Throwable throwable); void invokeListeners(Action4<T, Long, TimeUnit, A> invocationAction, long duration,
                                    TimeUnit timeUnit, A arg); void invokeListeners(Action5<T, Long, TimeUnit, Throwable, A> invocationAction, long duration,
                                    TimeUnit timeUnit, Throwable throwable, A arg); void invokeListeners(Action2<T, A> invocationAction, A arg); void invokeListeners(Action3<T, Throwable, A> invocationAction, Throwable throwable, A arg); ListenersHolder<T> copy(); void subscribeAllTo(EventSource<T> lazySource);  }