use of javax.servlet.ServletRequestEvent in project Payara by payara.
the class StandardContext method fireRequestInitializedEvent.
@Override
public void fireRequestInitializedEvent(ServletRequest request) {
List<EventListener> listeners = getApplicationEventListeners();
ServletRequestEvent event = null;
if (!listeners.isEmpty()) {
event = new ServletRequestEvent(getServletContext(), request);
// create pre-service event
Iterator<EventListener> iter = listeners.iterator();
while (iter.hasNext()) {
EventListener eventListener = iter.next();
if (!(eventListener instanceof ServletRequestListener)) {
continue;
}
ServletRequestListener listener = (ServletRequestListener) eventListener;
// START SJSAS 6329662
fireContainerEvent(ContainerEvent.BEFORE_REQUEST_INITIALIZED, listener);
// END SJSAS 6329662
try {
listener.requestInitialized(event);
} catch (Throwable t) {
String msg = MessageFormat.format(rb.getString(LogFacade.REQUEST_INIT_EXCEPTION), listener.getClass().getName());
log.log(Level.WARNING, msg, t);
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
// START SJSAS 6329662
} finally {
fireContainerEvent(ContainerEvent.AFTER_REQUEST_INITIALIZED, listener);
// END SJSAS 6329662
}
}
}
}
use of javax.servlet.ServletRequestEvent in project Payara by payara.
the class StandardContext method fireRequestDestroyedEvent.
@Override
public void fireRequestDestroyedEvent(ServletRequest request) {
List<EventListener> listeners = getApplicationEventListeners();
if (!listeners.isEmpty()) {
// create post-service event
ServletRequestEvent event = new ServletRequestEvent(getServletContext(), request);
int len = listeners.size();
for (int i = 0; i < len; i++) {
EventListener eventListener = listeners.get((len - 1) - i);
if (!(eventListener instanceof ServletRequestListener)) {
continue;
}
ServletRequestListener listener = (ServletRequestListener) eventListener;
// START SJSAS 6329662
fireContainerEvent(ContainerEvent.BEFORE_REQUEST_DESTROYED, listener);
// END SJSAS 6329662
try {
listener.requestDestroyed(event);
} catch (Throwable t) {
String msg = MessageFormat.format(rb.getString(LogFacade.REQUEST_DESTROY_EXCEPTION), listener.getClass().getName());
log.log(Level.WARNING, msg, t);
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
// START SJSAS 6329662
} finally {
fireContainerEvent(ContainerEvent.AFTER_REQUEST_DESTROYED, listener);
// END SJSAS 6329662
}
}
}
}
Aggregations