StandardContextValvepublic final class StandardContextValve extends org.apache.catalina.valves.ValveBase Valve that implements the default basic behavior for the
StandardContext container implementation.
USAGE CONSTRAINT: This implementation is likely to be useful only
when processing HTTP requests. |
Fields Summary |
---|
private static final String | infoThe descriptive information related to this implementation. | private static final org.apache.catalina.util.StringManager | smThe string manager for this package. | private StandardContext | context |
Methods Summary |
---|
public final void | event(org.apache.catalina.connector.Request request, org.apache.catalina.connector.Response response, org.apache.catalina.CometEvent event)Select the appropriate child Wrapper to process this request,
based on the specified request URI. If no matching Wrapper can
be found, return an appropriate HTTP error.
// Select the Wrapper to be used for this Request
Wrapper wrapper = request.getWrapper();
// Normal request processing
// FIXME: This could be an addition to the core API too
/*
Object instances[] = context.getApplicationEventListeners();
ServletRequestEvent event = null;
if ((instances != null)
&& (instances.length > 0)) {
event = new ServletRequestEvent
(((StandardContext) container).getServletContext(),
request.getRequest());
// create pre-service event
for (int i = 0; i < instances.length; i++) {
if (instances[i] == null)
continue;
if (!(instances[i] instanceof ServletRequestListener))
continue;
ServletRequestListener listener =
(ServletRequestListener) instances[i];
try {
listener.requestInitialized(event);
} catch (Throwable t) {
container.getLogger().error(sm.getString("requestListenerValve.requestInit",
instances[i].getClass().getName()), t);
ServletRequest sreq = request.getRequest();
sreq.setAttribute(Globals.EXCEPTION_ATTR,t);
return;
}
}
}
*/
wrapper.getPipeline().getFirst().event(request, response, event);
/*
if ((instances !=null ) &&
(instances.length > 0)) {
// create post-service event
for (int i = 0; i < instances.length; i++) {
if (instances[i] == null)
continue;
if (!(instances[i] instanceof ServletRequestListener))
continue;
ServletRequestListener listener =
(ServletRequestListener) instances[i];
try {
listener.requestDestroyed(event);
} catch (Throwable t) {
container.getLogger().error(sm.getString("requestListenerValve.requestDestroy",
instances[i].getClass().getName()), t);
ServletRequest sreq = request.getRequest();
sreq.setAttribute(Globals.EXCEPTION_ATTR,t);
}
}
}
*/
| public java.lang.String | getInfo()Return descriptive information about this Valve implementation.
// ------------------------------------------------------------- Properties
return (info);
| public final void | invoke(org.apache.catalina.connector.Request request, org.apache.catalina.connector.Response response)Select the appropriate child Wrapper to process this request,
based on the specified request URI. If no matching Wrapper can
be found, return an appropriate HTTP error.
// Disallow any direct access to resources under WEB-INF or META-INF
MessageBytes requestPathMB = request.getRequestPathMB();
if ((requestPathMB.startsWithIgnoreCase("/META-INF/", 0))
|| (requestPathMB.equalsIgnoreCase("/META-INF"))
|| (requestPathMB.startsWithIgnoreCase("/WEB-INF/", 0))
|| (requestPathMB.equalsIgnoreCase("/WEB-INF"))) {
String requestURI = request.getDecodedRequestURI();
notFound(requestURI, response);
return;
}
// Wait if we are reloading
while (context.getPaused()) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
;
}
}
// Select the Wrapper to be used for this Request
Wrapper wrapper = request.getWrapper();
if (wrapper == null) {
String requestURI = request.getDecodedRequestURI();
notFound(requestURI, response);
return;
}
// Normal request processing
Object instances[] = context.getApplicationEventListeners();
ServletRequestEvent event = null;
if ((instances != null)
&& (instances.length > 0)) {
event = new ServletRequestEvent
(((StandardContext) container).getServletContext(),
request.getRequest());
// create pre-service event
for (int i = 0; i < instances.length; i++) {
if (instances[i] == null)
continue;
if (!(instances[i] instanceof ServletRequestListener))
continue;
ServletRequestListener listener =
(ServletRequestListener) instances[i];
try {
listener.requestInitialized(event);
} catch (Throwable t) {
container.getLogger().error(sm.getString("standardContext.requestListener.requestInit",
instances[i].getClass().getName()), t);
ServletRequest sreq = request.getRequest();
sreq.setAttribute(Globals.EXCEPTION_ATTR,t);
return;
}
}
}
wrapper.getPipeline().getFirst().invoke(request, response);
if ((instances !=null ) &&
(instances.length > 0)) {
// create post-service event
for (int i = 0; i < instances.length; i++) {
if (instances[i] == null)
continue;
if (!(instances[i] instanceof ServletRequestListener))
continue;
ServletRequestListener listener =
(ServletRequestListener) instances[i];
try {
listener.requestDestroyed(event);
} catch (Throwable t) {
container.getLogger().error(sm.getString("standardContext.requestListener.requestDestroy",
instances[i].getClass().getName()), t);
ServletRequest sreq = request.getRequest();
sreq.setAttribute(Globals.EXCEPTION_ATTR,t);
}
}
}
| private void | notFound(java.lang.String requestURI, javax.servlet.http.HttpServletResponse response)Report a "not found" error for the specified resource. FIXME: We
should really be using the error reporting settings for this web
application, but currently that code runs at the wrapper level rather
than the context level.
try {
response.sendError(HttpServletResponse.SC_NOT_FOUND, requestURI);
} catch (IllegalStateException e) {
;
} catch (IOException e) {
;
}
| public void | setContainer(org.apache.catalina.Container container)Cast to a StandardContext right away, as it will be needed later.
super.setContainer(container);
context = (StandardContext) container;
|
|