public class RequestMapper extends Object
Modifier and Type | Field and Description |
---|---|
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.
|
static String |
REQUEST_CONTEXT_PREFIX
The name of an attribute for storing the prefix of URL
path corresponding to the
RequestHandler processing
the request. |
Constructor and Description |
---|
RequestMapper(Collection<RequestHandler> requestHandlers,
javax.servlet.ServletContext servletContext)
Construct a RequestMapper, for the given RequestHandler objects, on the
specified ServletContext.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public static final String REQUEST_CONTEXT_PREFIX
RequestHandler
processing
the request.public static final String GLOBAL_PRE_REQUEST_HANDLER
public static final String GLOBAL_POST_REQUEST_HANDLER
public RequestMapper(Collection<RequestHandler> requestHandlers, javax.servlet.ServletContext servletContext)
requestHandlers
- Collection of RequestHandlers which handle
requestsservletContext
- the webapp ServletContext where this RequestMapper
is configured.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 RequestHandlerpublic 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 clientjavax.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 handledpublic static String getRequestContextPath(javax.servlet.http.HttpServletRequest request)
request
- HttpServlet request object being handledpublic static String getRequestContextPathQuery(javax.servlet.http.HttpServletRequest request)
request
- HttpServlet request object being handledCopyright © 2005–2015 IIPC. All rights reserved.