FileDocCategorySizeDatePackage
ApplicationRequest.javaAPI DocApache Tomcat 6.0.146187Fri Jul 20 04:20:34 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: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $

Fields Summary
protected static final String[]
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 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



    // ----------------------------------------------------------- Constructors


                          
       

        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 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


        for (int i = 0; i < specials.length; i++) {
            if (specials[i].equals(name))
                return (true);
        }
        return (false);

    
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);
            }
        }