|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.archive.wayback.util.webapp.RequestMapper
public class RequestMapper
This class maintains a mapping of RequestHandlers and ShutDownListeners, to allow (somewhat) efficient mapping and delegation of incoming requests to the appropriate RequestHandler. This class uses PortMapper to delegate some of the responsibility of mapping requests received on a particular port, and also allows configuration of a global PRE RequestHandler, which gets first dibs on EVERY incoming request, as well as a global POST RequestHandler, which may attempt to handle any incoming request not handled by the normal RequestHandler mapping.
| Field Summary | |
|---|---|
static String |
GLOBAL_POST_REQUEST_HANDLER
Bean name used to register the special global POST RequestHandler. |
static String |
GLOBAL_PRE_REQUEST_HANDLER
Bean name used to register the special global PRE RequestHandler. |
| Constructor Summary | |
|---|---|
RequestMapper(Collection<RequestHandler> requestHandlers,
javax.servlet.ServletContext servletContext)
Construct a RequestMapper, for the given RequestHandler objects, on the specified ServletContext. |
|
| Method Summary | |
|---|---|
void |
addGlobalPostRequestHandler(RequestHandler requestHandler)
Configure the specified RequestHandler to handle ALL incoming requests after all other normal mapping has been attempted |
void |
addGlobalPreRequestHandler(RequestHandler requestHandler)
Configure the specified RequestHandler to handle ALL incoming requests before any other normal mapping. |
void |
addRequestHandler(int port,
String host,
String path,
RequestHandler requestHandler)
Register the RequestHandler to accept requests on the given port, for the specified host and path. |
void |
addShutdownListener(ShutdownListener shutdownListener)
Request the shutdownListener object to be notified of ServletContext shutdown. |
static String |
getRequestContextPath(javax.servlet.http.HttpServletRequest request)
|
static String |
getRequestContextPathQuery(javax.servlet.http.HttpServletRequest request)
|
static String |
getRequestPathPrefix(javax.servlet.http.HttpServletRequest request)
Extract the request path prefix, as computed at RequestHandler mapping, from the HttpServletRequest object. |
boolean |
handleRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Map the incoming request to the appropriate RequestHandler, including the PRE and POST RequestHandlers, if configured. |
RequestHandlerContext |
mapRequest(javax.servlet.http.HttpServletRequest request)
|
void |
shutdown()
notify all registered ShutdownListener objects that the ServletContext is being destroyed. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String GLOBAL_PRE_REQUEST_HANDLER
public static final String GLOBAL_POST_REQUEST_HANDLER
| Constructor Detail |
|---|
public RequestMapper(Collection<RequestHandler> requestHandlers,
javax.servlet.ServletContext servletContext)
requestHandlers - Collection of RequestHandlers which handle
requestsservletContext - the webapp ServletContext where this RequestMapper
is configured.| Method Detail |
|---|
public void addShutdownListener(ShutdownListener shutdownListener)
shutdownListener - the object which needs to have shutdown() called
when the ServletContext is destroyed.public void addGlobalPreRequestHandler(RequestHandler requestHandler)
requestHandler - the global PRE RequestHandlerpublic void addGlobalPostRequestHandler(RequestHandler requestHandler)
requestHandler - the global POST RequestHandler
public void addRequestHandler(int port,
String host,
String path,
RequestHandler requestHandler)
port - the integer port on which the RequestHandler gets requests.host - the String Host which the RequestHandler matches, or null, if
the RequestHandler should match ALL hosts.path - the String path which the RequestHandler matches, or null, if
the RequestHandler should match ALL paths.requestHandler - the RequestHandler to register.public RequestHandlerContext mapRequest(javax.servlet.http.HttpServletRequest request)
public boolean handleRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws IOException,
javax.servlet.ServletException
request - the incoming HttpServletRequestresponse - the HttpServletResponse to return data to the client
javax.servlet.ServletException - for usual reasons.
IOException - for usual reasons.public void shutdown()
public static String getRequestPathPrefix(javax.servlet.http.HttpServletRequest request)
request - HttpServlet request object being handled
public static String getRequestContextPath(javax.servlet.http.HttpServletRequest request)
request - HttpServlet request object being handled
public static String getRequestContextPathQuery(javax.servlet.http.HttpServletRequest request)
request - HttpServlet request object being handled
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||