FileDocCategorySizeDatePackage
ApplicationRequest.javaAPI DocGlassfish v2 API7399Fri May 04 22:31:54 BST 2007org.apache.catalina.core

ApplicationRequest

public class ApplicationRequest extends ServletRequestWrapper
Wrapper around a javax.servlet.ServletRequest that transforms an application request object (which might be the original one passed to a servlet, or might be based on the 2.3 javax.servlet.ServletRequestWrapper class) back into an internal org.apache.catalina.Request.

WARNING: Due to Java's lack of support for multiple inheritance, all of the logic in ApplicationRequest is duplicated in ApplicationHttpRequest. Make sure that you keep these two classes in synchronization when making changes!

author
Craig R. McClanahan
version
$Revision: 1.6 $ $Date: 2007/05/05 05:31:54 $

Fields Summary
private static final HashSet
specials
The set of attribute names that are special for request dispatchers.
protected HashMap
attributes
The request attributes for this request. This is initialized from the wrapped request, but updates are allowed.
protected static final org.apache.catalina.util.StringManager
sm
The string manager for this package.
Constructors Summary
public ApplicationRequest(ServletRequest request)
Construct a new wrapped request around the specified servlet request.

param
request The servlet request being wrapped



     
        specials.add(Globals.INCLUDE_REQUEST_URI_ATTR);
        specials.add(Globals.INCLUDE_CONTEXT_PATH_ATTR);
        specials.add(Globals.INCLUDE_SERVLET_PATH_ATTR);
        specials.add(Globals.INCLUDE_PATH_INFO_ATTR);
        specials.add(Globals.INCLUDE_QUERY_STRING_ATTR);
        specials.add(Globals.FORWARD_REQUEST_URI_ATTR);
        specials.add(Globals.FORWARD_CONTEXT_PATH_ATTR);
        specials.add(Globals.FORWARD_SERVLET_PATH_ATTR);
        specials.add(Globals.FORWARD_PATH_INFO_ATTR);
        specials.add(Globals.FORWARD_QUERY_STRING_ATTR);
    

        super(request);
        setRequest(request);

    
Methods Summary
public java.lang.ObjectgetAttribute(java.lang.String name)
Override the getAttribute() method of the wrapped request.

param
name Name of the attribute to retrieve



    // ------------------------------------------------- ServletRequest Methods


                         
        

        synchronized (attributes) {
            return (attributes.get(name));
        }

    
public java.util.EnumerationgetAttributeNames()
Override the getAttributeNames() method of the wrapped request.


        synchronized (attributes) {
            return (new Enumerator(attributes.keySet()));
        }

    
protected static booleanisSpecial(java.lang.String name)
Is this attribute name one of the special ones that is added only for included servlets?

param
name Attribute name to be tested


        return specials.contains(name);
    
public voidremoveAttribute(java.lang.String name)
Override the removeAttribute() method of the wrapped request.

param
name Name of the attribute to remove


        synchronized (attributes) {
            attributes.remove(name);
            if (!isSpecial(name))
                getRequest().removeAttribute(name);
        }

    
public voidsetAttribute(java.lang.String name, java.lang.Object value)
Override the setAttribute() method of the wrapped request.

param
name Name of the attribute to set
param
value Value of the attribute to set


        synchronized (attributes) {
            attributes.put(name, value);
            if (!isSpecial(name))
                getRequest().setAttribute(name, value);
        }

    
public voidsetRequest(javax.servlet.ServletRequest request)
Set the request that we are wrapping.

param
request The new wrapped request


        super.setRequest(request);

        // Initialize the attributes for this request
        synchronized (attributes) {
            attributes.clear();
            Enumeration names = request.getAttributeNames();
            while (names.hasMoreElements()) {
                String name = (String) names.nextElement();
                Object value = request.getAttribute(name);
                attributes.put(name, value);
            }
        }