org.benow.web.path
Class PathHandler

java.lang.Object
  extended by org.benow.web.path.PathHandler
Direct Known Subclasses:
CaptchaPathHandler, FileBasedPathHandler

public abstract class PathHandler
extends java.lang.Object

A path handler is responsible for handling data (usually html related) delivery for a certain path within the site. Some PathHandlers include the PagePathHandler which handles requests for .page xsl files and ServicePathHandler which provides an http interface to the ServiceManager.

Path handlers are registered via the ResourceValue method... that is, they require no special coding, but the ClassScanner (either seperately or within ResourceUtility) must be run before invocation (ie during ant jar creation) and the jar containing the path handler must be in the classpath. See ResourceUtility for details.

The order in which path handlers are selected is determined by it's position, which can be specified with the Position annotation. The default position (50) is used when no position is specified. To have the PathHandler apply sooner, specify a higer position or a lower position to apply later. The Position.FIRST and Position.LAST constants may be useful.

Author:
andy
See Also:
ResourceUtility, Position

Field Summary
protected static long CONTENT_LENGTH_UNKNOWN
           
protected static long LAST_MODIFIED_UNKNOWN
           
protected  QueryParams params
           
protected  javax.servlet.http.HttpServletRequest request
           
protected  javax.servlet.http.HttpServletResponse response
           
 
Constructor Summary
PathHandler()
           
 
Method Summary
abstract  boolean canHandle(java.lang.String fileName)
          Return true if the handler can handle the given path.
protected  void deliverHTML(java.io.PrintWriter out, java.lang.String html)
           
protected  void deliverStream(java.io.InputStream in, long contentLength, long lastModified, org.benow.java.mime.MimeType type)
           
protected  void deliverStream(java.io.InputStream in, org.benow.java.mime.MimeType type)
           
protected  void deliverStream(java.net.URL srcURL)
           
protected  java.lang.Object handle(java.io.OutputStream out)
           
 java.lang.Object handle(java.io.OutputStream out, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, QueryParams params)
           
protected  java.lang.Object handle(java.io.PrintWriter w)
           
protected  java.lang.Object handle(java.io.Writer w)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTENT_LENGTH_UNKNOWN

protected static final long CONTENT_LENGTH_UNKNOWN
See Also:
Constant Field Values

LAST_MODIFIED_UNKNOWN

protected static final long LAST_MODIFIED_UNKNOWN
See Also:
Constant Field Values

response

protected javax.servlet.http.HttpServletResponse response

params

protected QueryParams params

request

protected javax.servlet.http.HttpServletRequest request
Constructor Detail

PathHandler

public PathHandler()
Method Detail

handle

public final java.lang.Object handle(java.io.OutputStream out,
                                     javax.servlet.http.HttpServletRequest request,
                                     javax.servlet.http.HttpServletResponse response,
                                     QueryParams params)
                              throws java.lang.Exception
Throws:
java.lang.Exception

handle

protected java.lang.Object handle(java.io.OutputStream out)
                           throws java.lang.Exception
Throws:
java.lang.Exception

handle

protected java.lang.Object handle(java.io.Writer w)
                           throws java.io.IOException,
                                  WebException
Throws:
java.io.IOException
WebException

handle

protected java.lang.Object handle(java.io.PrintWriter w)
                           throws java.io.IOException,
                                  WebException
Throws:
java.io.IOException
WebException

deliverStream

protected void deliverStream(java.net.URL srcURL)
                      throws java.io.IOException,
                             org.benow.java.mime.CouldNotDivineMimeTypeException
Throws:
java.io.IOException
org.benow.java.mime.CouldNotDivineMimeTypeException

deliverStream

protected void deliverStream(java.io.InputStream in,
                             long contentLength,
                             long lastModified,
                             org.benow.java.mime.MimeType type)
                      throws java.io.FileNotFoundException,
                             java.io.IOException
Throws:
java.io.FileNotFoundException
java.io.IOException

deliverStream

protected void deliverStream(java.io.InputStream in,
                             org.benow.java.mime.MimeType type)
                      throws java.io.IOException
Throws:
java.io.IOException

deliverHTML

protected void deliverHTML(java.io.PrintWriter out,
                           java.lang.String html)
                    throws java.io.IOException
Throws:
java.io.IOException

canHandle

public abstract boolean canHandle(java.lang.String fileName)
                           throws WebException,
                                  java.io.IOException
Return true if the handler can handle the given path. Path is in format /dir/childdir/item.ext. It will never be null and will always start with a /.

Parameters:
fileName -
Returns:
Throws:
WebException
java.io.IOException