org.mortbay.jetty.handler
Class ResourceHandler

java.lang.Object
  extended byorg.mortbay.component.AbstractLifeCycle
      extended byorg.mortbay.jetty.handler.AbstractHandler
          extended byorg.mortbay.jetty.handler.ResourceHandler
All Implemented Interfaces:
Handler, LifeCycle

public class ResourceHandler
extends AbstractHandler

Resource Handler. This handle will serve static content and handle If-Modified-Since headers. No caching is done. Requests that cannot be handled are let pass (Eg no 404's)

Author:
Greg Wilkins (gregw)

Field Summary
 
Fields inherited from class org.mortbay.jetty.handler.AbstractHandler
_string
 
Fields inherited from interface org.mortbay.jetty.Handler
ALL, DEFAULT, ERROR, FORWARD, INCLUDE, REQUEST
 
Constructor Summary
ResourceHandler()
           
 
Method Summary
 Resource getBaseResource()
           
protected  Resource getResource(HttpServletRequest request)
           
 Resource getResource(String path)
           
 String getResourceBase()
           
protected  Resource getWelcome(Resource directory)
           
 String[] getWelcomeFiles()
           
 void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch)
          Handle a request.
 void setBaseResource(Resource base)
           
 void setResourceBase(String resourceBase)
           
 void setWelcomeFiles(String[] welcomeFiles)
           
 
Methods inherited from class org.mortbay.jetty.handler.AbstractHandler
doStart, doStop, getServer, setServer, toString
 
Methods inherited from class org.mortbay.component.AbstractLifeCycle
isFailed, isRunning, isStarted, isStarting, isStopping, 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
isFailed, isRunning, isStarted, isStarting, isStopping, start, stop
 

Constructor Detail

ResourceHandler

public ResourceHandler()
Method Detail

getBaseResource

public Resource getBaseResource()
Returns:
Returns the resourceBase.

getResourceBase

public String getResourceBase()
Returns:
Returns the base resource as a string.

setBaseResource

public void setBaseResource(Resource base)
Parameters:
base - The resourceBase to set.

setResourceBase

public void setResourceBase(String resourceBase)
Parameters:
resourceBase - The base resource as a string.

getResource

public Resource getResource(String path)
                     throws MalformedURLException
Throws:
MalformedURLException

getResource

protected Resource getResource(HttpServletRequest request)
                        throws MalformedURLException
Throws:
MalformedURLException

getWelcomeFiles

public String[] getWelcomeFiles()

setWelcomeFiles

public void setWelcomeFiles(String[] welcomeFiles)

getWelcome

protected Resource getWelcome(Resource directory)
                       throws MalformedURLException,
                              IOException
Throws:
MalformedURLException
IOException

handle

public void handle(String target,
                   HttpServletRequest request,
                   HttpServletResponse response,
                   int dispatch)
            throws IOException,
                   ServletException
Description copied from interface: Handler
Handle a request.

Parameters:
target - The target of the request - either a URI or a name.
request - The request either as the Request object or a wrapper of that request. The HttpConnection.getCurrentConnection() method can be used access the Request object if required.
response - The response as the Response object or a wrapper of that request. The HttpConnection.getCurrentConnection() method can be used access the Response object if required.
dispatch - The dispatch mode: Handler.REQUEST, Handler.FORWARD, Handler.INCLUDE, Handler.ERROR
Throws:
ServletException
IOException