public final class FailureCollector extends Object implements ExceptionCallback, Iterable<FailedEventInvocation>
FailureCollector collector = FailedEventsCollecter.create();
eventProvider.dispatch(myEvent, MyListener::handle, collector);
for (EventInvocation<?, ?> failed : collector) {
// ...
}
If you need to notify another ExceptionCallback, you can use the second
factory method. The following will collect all failed invocations and also
delegate them to the given other ExceptionCallback.
ExceptionCallback delegate = ...; FailureCollector collector = FailedEvents.delegatingTo(delegate); ...
| Modifier and Type | Method and Description |
|---|---|
static FailureCollector |
create()
Creates a new FailureCollector.
|
static FailureCollector |
delegatingTo(ExceptionCallback ec)
Creates a new FailureCollector which collects every failed notification
attempt, then handle the exception with the given delegate
ExceptionCallback. |
void |
exception(FailedEventInvocation invocation)
Callback method which is notified about exceptions that may occur during
event dispatching.
|
List<FailedEventInvocation> |
getFailedInvocations()
Gets the list of failed invocations that has been collected by this collector.
|
Iterator<FailedEventInvocation> |
iterator() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexceptionforEach, spliteratorpublic static FailureCollector delegatingTo(ExceptionCallback ec)
ExceptionCallback.ec - The delegate.public static FailureCollector create()
public List<FailedEventInvocation> getFailedInvocations()
public Iterator<FailedEventInvocation> iterator()
iterator in interface Iterable<FailedEventInvocation>public void exception(FailedEventInvocation invocation)
ExceptionCallbackEventProvider
if an instance of this interface has been set as exception callback. This
method is generally called within the same thread in which the attempt to
notify the listener has been made.
Note: If this method throws any unchecked exceptions other than
AbortionException, they will be swallowed by the EventProvider
during error handling.
Implementation note: the default implementation calls the deprecated method
ExceptionCallback.exception(Exception, Listener, Event) for compatibility reasons.
exception in interface ExceptionCallbackinvocation - FailedEventInvocation object which describes the failure.Copyright © 2014–2015. All rights reserved.