org.archive.wayback.util.webapp
Class PortMapper

java.lang.Object
  extended by org.archive.wayback.util.webapp.PortMapper

public class PortMapper
extends Object

Class which allows semi-efficient translation of requests on a specific local port to a RequestHandler object. Mapping within a port is based on the HTTP 1.1 Host field and the first segment of the requested PATH, that is, whatever is after the context where the wayback webapp was deployed, and before the first '/'.

Author:
brad

Constructor Summary
PortMapper(int port)
           
 
Method Summary
 void addRequestHandler(String host, String firstPath, RequestHandler requestHandler)
          Register the RequestHandler to accept requests for the given host and port.
 RequestHandlerContext getRequestHandlerContext(javax.servlet.http.HttpServletRequest request)
          Attempts to locate the most strictly matching RequestHandler mapped to this port.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PortMapper

public PortMapper(int port)
Parameters:
port - which this PortMapper is responsible for handling
Method Detail

addRequestHandler

public void addRequestHandler(String host,
                              String firstPath,
                              RequestHandler requestHandler)
Register the RequestHandler to accept requests for the given host and port.

Parameters:
host - the HTTP 1.1 "Host" header which the RequestHandler should match. If null, the RequestHandler matches any "Host" header value.
firstPath - the first path of the GET request path which the RequestHandler should match. This is the first path AFTER the name the Wayback webapp is deployed under. If null, the RequestHandler matches all paths.
requestHandler - The RequestHandler to register.

getRequestHandlerContext

public RequestHandlerContext getRequestHandlerContext(javax.servlet.http.HttpServletRequest request)
Attempts to locate the most strictly matching RequestHandler mapped to this port. Strictly matching means the lowest number in the following list: 1) request handler matching both HOST and PATH 2) request handler matching host, registered with an empty PATH 3) request handler matching path, registered with an empty HOST 4) request handler registered with empty HOST and PATH

Parameters:
request - the HttpServletRequest to be mapped to a RequestHandler
Returns:
the RequestHandlerContext, containing the RequestHandler and the prefix of the original request path that indicated the RequestHandler, or null, if no RequestHandler matches.


Copyright © 2005-2011 Internet Archive. All Rights Reserved.