boolean error = (event.getType() == EventType.ERROR) ? true : false;
Iterator<AsyncListenerRegistration> asyncListenerRegistrations =
asyncContext.getAsyncListeners().values().iterator();
while (asyncListenerRegistrations.hasNext()) {
AsyncListenerRegistration asyncListenerRegistration = asyncListenerRegistrations.next();
AsyncListener asyncListener = asyncListenerRegistration.getListener();
try {
if (timeout) {
AsyncEvent asyncEvent = new AsyncEvent(asyncContext,
asyncListenerRegistration.getRequest(), asyncListenerRegistration.getResponse());
asyncListener.onTimeout(asyncEvent);
} else if (error) {
Throwable t = (Throwable) request.getAttribute(Globals.EXCEPTION_ATTR);
AsyncEvent asyncEvent = new AsyncEvent(asyncContext,
asyncListenerRegistration.getRequest(), asyncListenerRegistration.getResponse(), t);
asyncListener.onError(asyncEvent);
} else {
AsyncEvent asyncEvent = new AsyncEvent(asyncContext,
asyncListenerRegistration.getRequest(), asyncListenerRegistration.getResponse());
asyncListener.onComplete(asyncEvent);
}
} catch (Throwable e) {
container.getLogger().error(sm.getString("standardWrapper.async.listenerError",
getContainer().getName()), e);
exception(request, response, e);