m.c.m.proxyma.resource
Class ProxymaServletRequest

java.lang.Object
  extended by m.c.m.proxyma.resource.ProxymaServletRequest
All Implemented Interfaces:
ProxymaRequest

public class ProxymaServletRequest
extends java.lang.Object
implements ProxymaRequest

This class implements a requests wrapper. It adapts servlet container requests to the Proxyma API. Through this class Proxyma can transparently handle any Servlet request.

NOTE: this software is released under GPL License. See the LICENSE of this distribution for more informations.

Version:
$Id: ProxymaServletRequest.java 176 2010-07-03 09:02:14Z marcolinuz $
Author:
Marco Casavecchia Morganti (marcolinuz) [marcolinuz-at-gmail.com]

Constructor Summary
ProxymaServletRequest(javax.servlet.http.HttpServletRequest aRequest, ProxymaContext theContext)
          Default constructor for this class.
 
Method Summary
 java.lang.String getCharacterEncoding()
          Returns the name of the character encoding style used in this request.
 java.lang.String getContentType()
          Returns the MIME type of the content of the request, or null if the type is not known.
 java.lang.String getContextURLPath()
          Returns the base path of proxyma from the request (without host, port, protocol and query string)
 javax.servlet.http.Cookie[] getCookies()
          Returns an array containing all of the Cookie objects the browser sent with this request.
 java.lang.String getHeader(java.lang.String headerName)
          Returns the value of the specified request header as a String.
 java.util.Enumeration<java.lang.String> getHeaderNames()
          Returns an enumeration of all the header names this request contains.
 java.util.Enumeration getHeaders(java.lang.String headerName)
          Returns all the values of the specified request header as an Enumeration of String objects.
 java.io.InputStream getInputStream()
          Returns the input stream for read the request's data sent by the client
 java.lang.String getMethod()
          Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
 java.lang.String getParameter(java.lang.String parameterName)
          Returns the value of the asked parameter
 java.util.Enumeration getParameterNames()
          Returns the names of the parameters into the request
 java.lang.String getProtocol()
          Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.
 java.lang.String getQueryString()
          Returns the query string that is contained in the request URL after the path.
 java.lang.String getRemoteAddress()
          Returns the Internet Protocol (IP) address of the client that sent the request.
 java.lang.String getRemoteHost()
          Returns the fully qualified name of the client that sent the request.
 java.lang.String getRemoteUser()
          Returns the name of the user making this request, if the user has logged in using HTTP authentication.
 java.lang.String getRequestURI()
          Get the absoute requested path (without protocol, host, port and query string)
 java.lang.String getScheme()
          Returns the sheme used by the client to send the request.
 java.lang.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.
 java.lang.String getSubPath()
          Returns the path of the request (without protocol, host, port, proxyma context and query string)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProxymaServletRequest

public ProxymaServletRequest(javax.servlet.http.HttpServletRequest aRequest,
                             ProxymaContext theContext)
Default constructor for this class. It thakes the original servlet request to wrap as parameter.

Parameters:
aRequest - the request to satisfy
theContext - the context where the request will live.
Method Detail

getHeaderNames

public java.util.Enumeration<java.lang.String> getHeaderNames()
Returns an enumeration of all the header names this request contains. If the request has no headers, this method returns an empty enumeration.

Specified by:
getHeaderNames in interface ProxymaRequest
Returns:
a collection of header names.

getHeader

public java.lang.String getHeader(java.lang.String headerName)
Returns the value of the specified request header as a String. If the named header wasn't sent with the request, this method returns null. The header name is case insensitive. You can use this method with any request header.

Specified by:
getHeader in interface ProxymaRequest
Returns:
the header value

getHeaders

public java.util.Enumeration getHeaders(java.lang.String headerName)
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 ProxymaRequest
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.

getContextURLPath

public java.lang.String getContextURLPath()
Returns the base path of proxyma from the request (without host, port, protocol and query string)

Specified by:
getContextURLPath in interface ProxymaRequest
Returns:
the absolute URI path that implements the current context.

getSubPath

public java.lang.String getSubPath()
Returns the path of the request (without protocol, host, port, proxyma context and query string)

Specified by:
getSubPath in interface ProxymaRequest
Returns:
the relative path from the proxyma base uri.

getRequestURI

public java.lang.String getRequestURI()
Get the absoute requested path (without protocol, host, port and query string)

Specified by:
getRequestURI in interface ProxymaRequest
Returns:
the absolute path of the requested URI.

getQueryString

public java.lang.String getQueryString()
Returns the query string that is contained in the request URL after the path. This method returns null if the URL does not have a query string.

Specified by:
getQueryString in interface ProxymaRequest
Returns:
the query string

getMethod

public java.lang.String getMethod()
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.

Specified by:
getMethod in interface ProxymaRequest
Returns:
GET, POST, PUT...

getParameter

public java.lang.String getParameter(java.lang.String parameterName)
Returns the value of the asked parameter

Specified by:
getParameter in interface ProxymaRequest
Parameters:
parameterName - The namwe of the reqested paramenter
Returns:
its value or null if it doesn't exists.

getParameterNames

public java.util.Enumeration getParameterNames()
Returns the names of the parameters into the request

Specified by:
getParameterNames in interface ProxymaRequest
Returns:
the parameter names.

getProtocol

public java.lang.String getProtocol()
Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.

Specified by:
getProtocol in interface ProxymaRequest
Returns:
the protocol

getContentType

public java.lang.String getContentType()
Returns the MIME type of the content of the request, or null if the type is not known.

Specified by:
getContentType in interface ProxymaRequest
Returns:
the value of the content-type header.

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Returns the name of the character encoding style used in this request. This method returns null if the request does not use character encoding.

Specified by:
getCharacterEncoding in interface ProxymaRequest
Returns:
the utf-8, iso-8859-1...

getCookies

public javax.servlet.http.Cookie[] getCookies()
Returns an array containing all of the Cookie objects the browser sent with this request. This method returns null if the browser did not send any cookies.

Specified by:
getCookies in interface ProxymaRequest
Returns:
an array of cookies

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns the input stream for read the request's data sent by the client

Specified by:
getInputStream in interface ProxymaRequest
Returns:
the request InputStream.
Throws:
java.io.IOException

getServerName

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

Specified by:
getServerName in interface ProxymaRequest
Returns:
the server host name.

getServerPort

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

Specified by:
getServerPort in interface ProxymaRequest
Returns:
the server port

getScheme

public java.lang.String getScheme()
Returns the sheme used by the client to send the request.

Specified by:
getScheme in interface ProxymaRequest
Returns:
http, http or ftp

getRemoteHost

public java.lang.String getRemoteHost()
Returns the fully qualified name of the client that sent the request.

Specified by:
getRemoteHost in interface ProxymaRequest
Returns:
the client host name

getRemoteAddress

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

Specified by:
getRemoteAddress in interface ProxymaRequest
Returns:
the ip of the client

getRemoteUser

public java.lang.String getRemoteUser()
Returns the name of the user making this request, if the user has logged in using HTTP authentication. This method returns null if the user login is not authenticated. Whether the user name is sent with each subsequent request depends on the browser.

Specified by:
getRemoteUser in interface ProxymaRequest
Returns:
the name of the authenticated user


Copyright © 2010. All Rights Reserved.