org.norther.tammi.spray.protocol.chain
Class AbstractProtocolRequest

java.lang.Object
  extended by javax.servlet.ServletRequestWrapper
      extended by org.norther.tammi.spray.filter.chain.ServletRequestWrapper
          extended by org.norther.tammi.spray.filter.chain.HttpServletRequestWrapper
              extended by org.norther.tammi.spray.protocol.chain.AbstractProtocolRequest
All Implemented Interfaces:
EventListener, HttpServletRequest, ServletRequest, Poolable, Recyclable, FilterChainListener
Direct Known Subclasses:
BaseProtocolRequest, HttpServletRequestDecorator

public abstract class AbstractProtocolRequest
extends HttpServletRequestWrapper

An abstract protocol request implementing the ProtocolExtension interface as an inner class and extended parameter methods.

Author:
Ilkka Priha

Nested Class Summary
protected  class AbstractProtocolRequest.ProtocolRequestExtension
          The protocol extension class.
 
Field Summary
protected static int BODY_PARSED
          The body parsed mask.
protected static int COOKIE_SESSION
          The cookie session mask.
protected static int HEADERS_PARSED
          The headers parsed mask.
protected static int REQUEST_PARSED
          The request parsed mask.
protected static int URI_PARSED
          The URI parsed mask.
protected static int URL_SESSION
          The URL parsed mask.
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
AbstractProtocolRequest()
          Constructs a new request.
AbstractProtocolRequest(ServletRequest req)
          Constructs a new request with a wrapped one.
 
Method Summary
protected  void addParameter(String key, String value)
          Adds a parameter value to the parameter map.
protected  void addParameter(String key, String[] values)
          Adds parameter values to the parameter map.
protected  void addParameterMap(Map map)
          Adds a parameter map to the parameter map.
 void dispose()
          Disposes the object after use.
protected abstract  void drain()
          Drains a HTTP/1.1 request to guarantee a fresh stream for the next round.
protected  StringBuilder getAuthorityURL()
          Gets the authority URL of the request including the scheme, server name and port.
protected  StringBuilder getAuthorityURL(boolean secure)
          Gets the authority URL of the request including the scheme, server name and port.
protected  StringBuilder getAuthorityURL(String host, int port, boolean secure)
          Gets the authority URL of the request including the scheme, server name and port.
protected  HttpFilter getHttpFilter()
          Gets the HTTP filter.
protected  String getInternalCharacterEncoding()
          Gets the internal character encoding of the request.
 String getParameter(String name)
           
 Map getParameterMap()
           
 Enumeration getParameterNames()
           
 String[] getParameterValues(String name)
           
protected  Map getParsedParameterMap()
          Gets the parsed parameters as a map of names and value arrays.
protected  String getPathTail()
          Gets the tail of the path info.
protected  String getRedirectionURL()
          Gets the redirection URL of this request.
protected  float getVersion()
          Gets the protocol version of the request.
protected  boolean isAuthentication()
          Checks whether the request is an authentication.
protected  boolean isRedirection()
          Checks whether this request is a redirection.
protected  boolean isSecureSession()
          Checks whether the session is secure.
protected  void removeParameter(String key)
          Removes parameter values from the parameter map.
protected  void setAuthentication(boolean flag)
          Sets whether the request is an authentication.
protected  void setParameter(String key, String[] values)
          Sets parameter values to the parameter map.
protected  void setRedirection(boolean flag)
          Sets whether this request is a redirection.
protected  void setRedirectionURL(String url)
          Sets the redirection URL of this request.
 
Methods inherited from class org.norther.tammi.spray.filter.chain.HttpServletRequestWrapper
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole, setRequest
 
Methods inherited from class org.norther.tammi.spray.filter.chain.ServletRequestWrapper
completed, disposed, filtered, getExtension, getFilterChain, getFilteredRequest, getFilteredResponse, isDisposed, recycle, recycle, recycled, setExtension
 
Methods inherited from class javax.servlet.ServletRequestWrapper
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.ServletRequest
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding
 

Field Detail

REQUEST_PARSED

protected static final int REQUEST_PARSED
The request parsed mask.

See Also:
Constant Field Values

HEADERS_PARSED

protected static final int HEADERS_PARSED
The headers parsed mask.

See Also:
Constant Field Values

BODY_PARSED

protected static final int BODY_PARSED
The body parsed mask.

See Also:
Constant Field Values

URI_PARSED

protected static final int URI_PARSED
The URI parsed mask.

See Also:
Constant Field Values

URL_SESSION

protected static final int URL_SESSION
The URL parsed mask.

See Also:
Constant Field Values

COOKIE_SESSION

protected static final int COOKIE_SESSION
The cookie session mask.

See Also:
Constant Field Values
Constructor Detail

AbstractProtocolRequest

public AbstractProtocolRequest()
Constructs a new request.


AbstractProtocolRequest

public AbstractProtocolRequest(ServletRequest req)
Constructs a new request with a wrapped one.

Parameters:
req - the wrapped request.
Method Detail

dispose

public void dispose()
Description copied from interface: Recyclable
Disposes the object after use. The method is called when the object is returned to its pool. The dispose method must call its super.

Specified by:
dispose in interface Recyclable
Overrides:
dispose in class HttpServletRequestWrapper

getParameter

public String getParameter(String name)
Specified by:
getParameter in interface ServletRequest
Overrides:
getParameter in class ServletRequestWrapper

getParameterValues

public String[] getParameterValues(String name)
Specified by:
getParameterValues in interface ServletRequest
Overrides:
getParameterValues in class ServletRequestWrapper

getParameterNames

public Enumeration getParameterNames()
Specified by:
getParameterNames in interface ServletRequest
Overrides:
getParameterNames in class ServletRequestWrapper

getParameterMap

public Map getParameterMap()
Specified by:
getParameterMap in interface ServletRequest
Overrides:
getParameterMap in class ServletRequestWrapper

drain

protected abstract void drain()
Drains a HTTP/1.1 request to guarantee a fresh stream for the next round.


getVersion

protected float getVersion()
Gets the protocol version of the request.

Returns:
the version.

getPathTail

protected String getPathTail()
Gets the tail of the path info.

Returns:
the path tail or null.

isRedirection

protected boolean isRedirection()
Checks whether this request is a redirection.

Returns:
true if a redirection, otherwise false.

setRedirection

protected void setRedirection(boolean flag)
Sets whether this request is a redirection.

Parameters:
flag - true if a redirection, otherwise false.

isAuthentication

protected boolean isAuthentication()
Checks whether the request is an authentication.

Returns:
true if an authentication, otherwise false.

setAuthentication

protected void setAuthentication(boolean flag)
Sets whether the request is an authentication.

Parameters:
flag - true if an authentication, otherwise false.

getRedirectionURL

protected String getRedirectionURL()
Gets the redirection URL of this request.

Returns:
the redirection URL or null.

setRedirectionURL

protected void setRedirectionURL(String url)
Sets the redirection URL of this request.

Parameters:
url - the redirection URL.

isSecureSession

protected boolean isSecureSession()
Checks whether the session is secure.

Returns:
true if secure, otherwise false.

getAuthorityURL

protected StringBuilder getAuthorityURL()
Gets the authority URL of the request including the scheme, server name and port.

Returns:
the authority URL.

getAuthorityURL

protected StringBuilder getAuthorityURL(boolean secure)
Gets the authority URL of the request including the scheme, server name and port. The specified scheme is applied.

Parameters:
secure - a flag to use https scheme.
Returns:
the authority URL.

getAuthorityURL

protected StringBuilder getAuthorityURL(String host,
                                        int port,
                                        boolean secure)
Gets the authority URL of the request including the scheme, server name and port. The specified scheme, host and port are applied.

Parameters:
host - the server name to use (null = default).
port - the port number to use (0 = default).
secure - a flag to use https scheme.
Returns:
the authority URL.

getInternalCharacterEncoding

protected String getInternalCharacterEncoding()
Gets the internal character encoding of the request.

Returns:
the character encoding.

addParameter

protected void addParameter(String key,
                            String value)
Adds a parameter value to the parameter map.

Parameters:
key - the parameter key.
value - the parameter value.

addParameter

protected void addParameter(String key,
                            String[] values)
Adds parameter values to the parameter map.

Parameters:
key - the parameter key.
values - the parameter values.

setParameter

protected void setParameter(String key,
                            String[] values)
Sets parameter values to the parameter map.

Parameters:
key - the parameter key.
values - the parameter values.

removeParameter

protected void removeParameter(String key)
Removes parameter values from the parameter map.

Parameters:
key - the parameter key.

addParameterMap

protected void addParameterMap(Map map)
Adds a parameter map to the parameter map.

Parameters:
map - the parameter map.

getParsedParameterMap

protected Map getParsedParameterMap()
Gets the parsed parameters as a map of names and value arrays.

Returns:
the parsed parameters as a map.

getHttpFilter

protected HttpFilter getHttpFilter()
Gets the HTTP filter.

Returns:
the HTTP filter.
Throws:
IllegalStateException - if not available.


Copyright © 2004 The Norther Organization. All rights reserved.