AdHocContextValvepublic class AdHocContextValve extends Object implements org.apache.catalina.ValveImplementation of StandardContextValve which is added as the base valve
to a web module's ad-hoc pipeline.
A web module's ad-hoc pipeline is invoked for any of the web module's
ad-hoc paths.
The AdHocContextValve is responsible for invoking the ad-hoc servlet
associated with the ad-hoc path. |
Fields Summary |
---|
private static final Logger | LOGGER | private static final String | VALVE_INFO | private WebModule | context |
Constructors Summary |
---|
public AdHocContextValve(WebModule context)Constructor.
this.context = context;
|
Methods Summary |
---|
public java.lang.String | getInfo()Returns descriptive information about this valve.
return VALVE_INFO;
| public int | invoke(org.apache.catalina.Request request, org.apache.catalina.Response response)Processes the given request by passing it to the ad-hoc servlet
associated with the request path (which has been determined, by the
associated web module, to be an ad-hoc path).
HttpServletRequest hreq = (HttpServletRequest) request.getRequest();
HttpServletResponse hres = (HttpServletResponse) response.getResponse();
String adHocServletName =
context.getAdHocServletName(hreq.getServletPath());
Wrapper adHocWrapper = (Wrapper) context.findChild(adHocServletName);
if (adHocWrapper != null) {
Servlet adHocServlet = null;
try {
adHocServlet = adHocWrapper.allocate();
adHocServlet.service(hreq, hres);
} catch (Throwable t) {
hres.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
String msg = LOGGER.getResourceBundle().getString(
"webmodule.adHocContextValve.adHocServletServiceError");
msg = MessageFormat.format(
msg,
new Object[] { hreq.getServletPath() });
response.setDetailMessage(msg);
return END_PIPELINE;
} finally {
if (adHocServlet != null) {
adHocWrapper.deallocate(adHocServlet);
}
}
} else {
hres.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
String msg = LOGGER.getResourceBundle().getString(
"webmodule.adHocContextValve.noAdHocServlet");
msg = MessageFormat.format(
msg,
new Object[] { hreq.getServletPath() });
response.setDetailMessage(msg);
return END_PIPELINE;
}
return END_PIPELINE;
| public void | postInvoke(org.apache.catalina.Request request, org.apache.catalina.Response response)
// Do nothing
|
|