com.cafesoft.cams.agent.http
Class AbstractCamsHttpAgentRequest

java.lang.Object
  |
  +--com.cafesoft.cams.agent.http.AbstractCamsHttpAgentRequest
All Implemented Interfaces:
CamsHttpAgentRequest

public abstract class AbstractCamsHttpAgentRequest
extends Object
implements CamsHttpAgentRequest

Abstract implementation of CamsHttpAgentRequest.

Since:
1/22/02

Field Summary
protected  Logger logger
          Logs data.
protected  javax.servlet.http.HttpServletRequest request
          The HttpServletRequest cast from the more general Request.
 
Constructor Summary
AbstractCamsHttpAgentRequest()
           
AbstractCamsHttpAgentRequest(javax.servlet.http.HttpServletRequest request)
          Create a new AbstractCamsHttpAgentRequest.
 
Method Summary
abstract  void addHeader(String name, String value)
          Adds the specified header and value to this CamsHttpAgentRequest.
 void destroy()
          Destroy the CamsHttpAgentRequest.
 javax.servlet.http.Cookie[] getCookies(HttpCookieFilter filter)
          Returns an array containing all of the Cookie objects the client sent with this request.
 String getHeader(String name)
          Returns the value of the specified request header as a String.
 Enumeration getHeaderNames()
          Returns an enumeration of all the header names this request contains.
 Enumeration getHeaders(String name)
          Returns all the values of the specified request header as an Enumeration of String objects.
 String getMethod()
          Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
 String getParameter(String name)
          Returns the value mapped to the specified parameter.
 Enumeration getParameterNames()
          Returns all of the Http parameters.
 String getProtocol()
          Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.
 String getQueryString()
          Returns the query string that is contained in the request URL after the path.
 String getRemoteAddr()
          Returns the Internet Protocol (IP) address of the client that sent the request.
 String getRemoteHost()
          Returns the fully qualified name of the client that sent the request.
 String getRequestURI()
          Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
 String getRequestURL()
          Reconstructs the URL the client used to make the request.
 String getScheme()
          Returns the name of the scheme used to make this request.
 String getServerAddr()
          Returns the IP address of the server where the CamsHttpAgent is running.
 String getServerName()
          Returns the host name of the server that received the request.
 int getServerPort()
          Returns the port number on which this request was received.
 SessionId getSessionId()
          Get the session id if one exists from the CamsHttpAgentRequest object.
 void initialize(Config config)
          Initializes this request.
 boolean isLogin()
          Determines if this Http request is for logging in.
 boolean isLogout()
          Determines if this Http request is for logging out.
 boolean isSecure()
          Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
 void log()
          Logs the data contained in this CamsHttpAgentRequest.
 void recycle()
          Recycle the CamsHttpAgentRequest so it can be reused.
 void setRequest(javax.servlet.http.HttpServletRequest request)
          Sets the Request object.
 void setSessionId(SessionId sessionId)
          Set the session id.
 void validateHeaders()
          Validate the request headers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

request

protected javax.servlet.http.HttpServletRequest request
The HttpServletRequest cast from the more general Request. This will be much more practical for most uses in this class.


logger

protected Logger logger
Logs data.

Constructor Detail

AbstractCamsHttpAgentRequest

public AbstractCamsHttpAgentRequest()

AbstractCamsHttpAgentRequest

public AbstractCamsHttpAgentRequest(javax.servlet.http.HttpServletRequest request)
Create a new AbstractCamsHttpAgentRequest.

Parameters:
request - the Http request
Throws:
NullPointerException - thrown if the request is null
Method Detail

addHeader

public abstract void addHeader(String name,
                               String value)
Adds the specified header and value to this CamsHttpAgentRequest.

Specified by:
addHeader in interface CamsHttpAgentRequest
Parameters:
name - the name of the header
value - the value of the header

validateHeaders

public void validateHeaders()
                     throws CamsHttpAgentException
Validate the request headers.

Specified by:
validateHeaders in interface CamsHttpAgentRequest
Throws:
CamsHttpAgentException - if any header name starts with the prefix CAMS_. The message of the exception is the name of the request header that was invalid.

setRequest

public void setRequest(javax.servlet.http.HttpServletRequest request)
Sets the Request object.

Parameters:
request - contains the Http request data

initialize

public void initialize(Config config)
Initializes this request.

Parameters:
config - contains configuration data

getParameter

public String getParameter(String name)
Returns the value mapped to the specified parameter.

Specified by:
getParameter in interface CamsHttpAgentRequest
Parameters:
name - the name of the parameter
Returns:
the value mapped to the specified parameter

getParameterNames

public Enumeration getParameterNames()
Returns all of the Http parameters.

Specified by:
getParameterNames in interface CamsHttpAgentRequest
Returns:
all of the Http parameter names

getRemoteAddr

public String getRemoteAddr()
Returns the Internet Protocol (IP) address of the client that sent the request.

Specified by:
getRemoteAddr in interface CamsHttpAgentRequest
Returns:
a String containing the IP address of the client that sent the request

getRemoteHost

public String getRemoteHost()
Returns the fully qualified name of the client that sent the request. If the hostname cannot be resolved, this method returns the dotted-string form of the IP address.

Specified by:
getRemoteHost in interface CamsHttpAgentRequest
Returns:
a String containing the fully qualified name of the client

getProtocol

public String getProtocol()
Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1. For HTTP servlets, the value returned is the same as the value of the CGI variable SERVER_PROTOCOL.

Specified by:
getProtocol in interface CamsHttpAgentRequest
Returns:
a String containing the protocol name and version number

getScheme

public String getScheme()
Returns the name of the scheme used to make this request.

Specified by:
getScheme in interface CamsHttpAgentRequest
Returns:
the scheme. For example, http or https.

getServerName

public String getServerName()
Returns the host name of the server that received the request.

Specified by:
getServerName in interface CamsHttpAgentRequest

getServerAddr

public String getServerAddr()
Returns the IP address of the server where the CamsHttpAgent is running.

Specified by:
getServerAddr in interface CamsHttpAgentRequest
Returns:
the server's IP address as a String

getServerPort

public int getServerPort()
Returns the port number on which this request was received.

Specified by:
getServerPort in interface CamsHttpAgentRequest

isSecure

public boolean isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.

Specified by:
isSecure in interface CamsHttpAgentRequest

getMethod

public String getMethod()
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. Same as the value of the CGI variable REQUEST_METHOD.

Specified by:
getMethod in interface CamsHttpAgentRequest
Returns:
a String specifying the name of the method with which this request was made

getQueryString

public String getQueryString()
Returns the query string that is contained in the request URL after the path. This method returns if the URL does not have a query string. Same as the value of the CGI variable QUERY_STRING.

Specified by:
getQueryString in interface CamsHttpAgentRequest
Returns:
a String containing the query string or null if the URL contains no query string. The value is not decoded by the container.

getRequestURI

public String getRequestURI()
Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request. The web container does not decode this String. For example: First line of HTTP request Returned Value POST /some/path.html HTTP/1.1 returns: /some/path.html GET http://foo.bar/a.html HTTP/1.0 returns: /a.html HEAD /xyz?a=b HTTP/1.1 returns: /xyz

Specified by:
getRequestURI in interface CamsHttpAgentRequest
Returns:
a String containing the part of the URL from the protocol name up to the query string

getRequestURL

public String getRequestURL()
Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.

Specified by:
getRequestURL in interface CamsHttpAgentRequest
Returns:
a String containing the reconstructed URL

getCookies

public javax.servlet.http.Cookie[] getCookies(HttpCookieFilter filter)
Returns an array containing all of the Cookie objects the client sent with this request. This method returns null if no cookies were sent.

Specified by:
getCookies in interface CamsHttpAgentRequest
Returns:
an array of all the Cookies included with this request, or null if the request has no cookies.

getHeader

public String getHeader(String name)
Returns the value of the specified request header as a String. If the request did not include a header of the specified name, this method returns null. The header name is case insensitive. You can use this method with any request header.

Specified by:
getHeader in interface CamsHttpAgentRequest
Parameters:
name - a String specifying the header name
Returns:
a String containing the value of the requested header, or null if the request does not have a header of that name

getHeaders

public Enumeration getHeaders(String name)
Returns all the values of the specified request header as an Enumeration of String objects.

Some headers, such as Accept-Language can be sent by clients as several headers each with a different value rather than sending the header as a comma separated list.

If the request did not include any headers of the specified name, this method returns an empty Enumeration. The header name is case insensitive. You can use this method with any request header.

Specified by:
getHeaders in interface CamsHttpAgentRequest
Parameters:
name - a String specifying the header name
Returns:
an Enumeration containing the values of the requested header. If the request does not have any headers of that name return an empty enumeration. If the container does not allow access to header information, return null

getHeaderNames

public Enumeration getHeaderNames()
Returns an enumeration of all the header names this request contains. If the request has no headers, this method returns an empty enumeration. Some servlet containers do not allow do not allow servlets to access headers using this method, in which case this method returns null

Specified by:
getHeaderNames in interface CamsHttpAgentRequest
Returns:
an enumeration of all the header names sent with this request; if the request has no headers, an empty enumeration; if the servlet container does not allow servlets to use this method, null

setSessionId

public void setSessionId(SessionId sessionId)
Set the session id.

Specified by:
setSessionId in interface CamsHttpAgentRequest
Parameters:
sessionId - the session id or null if one is not set

getSessionId

public SessionId getSessionId()
Get the session id if one exists from the CamsHttpAgentRequest object.

Specified by:
getSessionId in interface CamsHttpAgentRequest
Returns:
the session id or null if one is not set

isLogin

public boolean isLogin()
Determines if this Http request is for logging in.

Specified by:
isLogin in interface CamsHttpAgentRequest
Returns:
true if this Http request is for logging in, false otherwise

isLogout

public boolean isLogout()
Determines if this Http request is for logging out.

Specified by:
isLogout in interface CamsHttpAgentRequest
Returns:
true if this Http request is for logging out, false otherwise

recycle

public void recycle()
Recycle the CamsHttpAgentRequest so it can be reused.

Specified by:
recycle in interface CamsHttpAgentRequest

destroy

public void destroy()
Destroy the CamsHttpAgentRequest.

This method will destroy the CamsHttpAgentRequest object. This method should be used when the CamsHttpAgentRequest will no longer be used. This method should destroy everything including underlying collections.

Specified by:
destroy in interface CamsHttpAgentRequest

log

public void log()
Logs the data contained in this CamsHttpAgentRequest.

Specified by:
log in interface CamsHttpAgentRequest


Generated on 10:40:31 AM September 10, 2003, © 1996-2003 Cafésoft LLC. All rights reserved.