dk.netarkivet.viewerproxy
Class WebProxy

java.lang.Object
  extended by org.mortbay.component.AbstractLifeCycle
      extended by org.mortbay.jetty.handler.AbstractHandler
          extended by org.mortbay.jetty.handler.DefaultHandler
              extended by dk.netarkivet.viewerproxy.WebProxy
All Implemented Interfaces:
URIResolverHandler, org.mortbay.component.LifeCycle, org.mortbay.jetty.Handler

public class WebProxy
extends org.mortbay.jetty.handler.DefaultHandler
implements URIResolverHandler

The WebProxy is the ONLY viewerproxy class that interfaces with the Jetty classes. This class packages all requests up nicely as calls to uriResolver.lookup(). In particular, it handles the control of the Jetty server that the Proxy server builds on.


Nested Class Summary
static class WebProxy.HttpRequest
          A wrapper around the Jetty HttpRequest, giving the simple Request interface used in our URIResolvers.
static class WebProxy.HttpResponse
          A wrapper around the Jetty HttpResponse, giving the simple Response interface used in our URIResolvers.
 
Nested classes/interfaces inherited from interface org.mortbay.component.LifeCycle
org.mortbay.component.LifeCycle.Listener
 
Field Summary
 
Fields inherited from class org.mortbay.jetty.handler.AbstractHandler
_string
 
Fields inherited from class org.mortbay.component.AbstractLifeCycle
_listeners
 
Fields inherited from interface org.mortbay.jetty.Handler
ALL, DEFAULT, ERROR, FORWARD, INCLUDE, REQUEST
 
Constructor Summary
WebProxy(URIResolver uriResolver)
          Initialises a new web proxy, which delegates lookups to the given uri resolver.
 
Method Summary
 void handle(java.lang.String target, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, int dispatch)
          Handle an HTTP request.
 void kill()
          Shut down this server.
 void setURIResolver(URIResolver ur)
          Sets the current URIResolver.
 
Methods inherited from class org.mortbay.jetty.handler.DefaultHandler
getServeIcon, setServeIcon
 
Methods inherited from class org.mortbay.jetty.handler.AbstractHandler
destroy, doStart, doStop, getServer, setServer, toString
 
Methods inherited from class org.mortbay.component.AbstractLifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mortbay.component.LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 

Constructor Detail

WebProxy

public WebProxy(URIResolver uriResolver)
Initialises a new web proxy, which delegates lookups to the given uri resolver. The WebProxy will start listening on port given in settings.

Parameters:
uriResolver - The uriResolver used to handle lookups in the proxy.
Throws:
IOFailure - on trouble starting the proxy server.
ArgumentNotValid - on null uriResolver.
Method Detail

setURIResolver

public void setURIResolver(URIResolver ur)
Sets the current URIResolver.

Specified by:
setURIResolver in interface URIResolverHandler
Parameters:
ur - The resolver to handle lookups.
Throws:
ArgumentNotValid - on null uriResolver.

handle

public void handle(java.lang.String target,
                   javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response,
                   int dispatch)
Handle an HTTP request. Overrides default behaviour of Jetty. This will forward the URI and response to the wrapped URI resolver. Note that the server will NOT force the return value to be the one returned by the uri resolver, rather it will use the one the uri resolver has set in the response object. Exceptions will generate an internal server error-page with the details.

Specified by:
handle in interface org.mortbay.jetty.Handler
Overrides:
handle in class org.mortbay.jetty.handler.DefaultHandler
Parameters:
target - URL or name for request. Not used
request - The original request, including URL
response - The object that receives the result
dispatch - The dispatch mode. Not used.
See Also:
Handler.handle(java.lang.String, HttpServletRequest, HttpServletResponse, int)

kill

public void kill()
Shut down this server.