cziegeler    2002/12/05 06:21:37

  Modified:    src/java/org/apache/cocoon/environment/wrapper
                        EnvironmentWrapper.java
               src/java/org/apache/cocoon/environment/http HttpRequest.java
                        HttpContext.java HttpResponse.java
               src/java/org/apache/cocoon/environment
                        ForwardRedirector.java
  Log:
  Minor performance improvement and securing instance variables
  
  Revision  Changes    Path
  1.24      +9 -39     
xml-cocoon2/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java
  
  Index: EnvironmentWrapper.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- EnvironmentWrapper.java   3 Dec 2002 16:04:44 -0000       1.23
  +++ EnvironmentWrapper.java   5 Dec 2002 14:21:36 -0000       1.24
  @@ -86,28 +86,28 @@
       protected Environment environment;
   
       /** The object model */
  -    private Map objectModel;
  +    protected Map objectModel;
   
       /** The redirect url */
  -    private String redirectURL;
  +    protected String redirectURL;
   
       /** The request object */
  -    private Request request;
  +    protected Request request;
   
       /** The last context */
  -    private URL lastContext;
  +    protected URL lastContext;
   
       /** The last prefix */
  -    private String lastPrefix;
  +    protected String lastPrefix;
   
       /** The last uri */
  -    private String lastURI;
  +    protected String lastURI;
   
       /** The stream to output to */
  -    private OutputStream outputStream;
  +    protected OutputStream outputStream;
   
       /** The processor used */
  -    private Processor processor;
  +    protected Processor processor;
   
       /**
        * Constructs an EnvironmentWrapper object from a Request
  @@ -352,36 +352,6 @@
           this.setURIPrefix(this.lastPrefix);
           this.uris = this.lastURI;
           return this.processor;
  -    }
  -
  -    /**
  -     * Lookup an attribute in this instance, and if not found search it
  -     * in the wrapped environment.
  -     *
  -     * @param name a <code>String</code>, the name of the attribute to
  -     * look for
  -     * @return an <code>Object</code>, the value of the attribute or
  -     * null if no such attribute was found.
  -     */
  -    public Object getAttribute(String name)
  -    {
  -        Object value = super.getAttribute(name);
  -        if (value == null)
  -            value = environment.getAttribute(name);
  -
  -        return value;
  -    }
  -
  -    /**
  -     * Remove attribute from the current instance, as well as from the
  -     * wrapped environment.
  -     *
  -     * @param name a <code>String</code> value
  -     */
  -    public void removeAttribute(String name)
  -    {
  -        super.removeAttribute(name);
  -        environment.removeAttribute(name);
       }
   
       /**
  
  
  
  1.12      +18 -11    
xml-cocoon2/src/java/org/apache/cocoon/environment/http/HttpRequest.java
  
  Index: HttpRequest.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/http/HttpRequest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- HttpRequest.java  21 Nov 2002 18:18:49 -0000      1.11
  +++ HttpRequest.java  5 Dec 2002 14:21:36 -0000       1.12
  @@ -71,24 +71,28 @@
    * @version CVS $Id$
    */
   
  -public class HttpRequest implements Request {
  +public final class HttpRequest implements Request {
   
       /** The real HttpServletRequest object */
  -    private HttpServletRequest req = null;
  +    private final HttpServletRequest req;
   
       /** The HttpEnvironment object */
  -    private HttpEnvironment env = null;
  +    private final HttpEnvironment env;
   
       /** The character encoding of parameters */
  -    private String form_encoding = null;
  +    private String form_encoding;
   
       /** The default form encoding of the servlet container */
  -    private String container_encoding = null;
  +    private String container_encoding;
       
  +    /** The current session */
  +    private HttpSession session;
  +
       private final RequestFactory requestFactory;
   
  +    
       /**
  -     * Creates a HttpServletRequest based on a real HttpServletRequest object
  +     * Creates a HttpRequest based on a real HttpServletRequest object
        */
       protected HttpRequest(HttpServletRequest req, HttpEnvironment env, 
RequestFactory requestFactory) {
           super();
  @@ -220,10 +224,13 @@
       }
   
       public Session getSession(boolean create) {
  -        javax.servlet.http.HttpSession session = this.req.getSession(create);
  -        if(session != null)
  -            return new HttpSession(session);
  -        return null;
  +        if ( null == this.session ) {
  +            javax.servlet.http.HttpSession serverSession = 
this.req.getSession(create);
  +            if( null != serverSession ) {
  +                this.session = new HttpSession( serverSession );
  +            }
  +        }
  +        return this.session;
       }
   
       public Session getSession() {
  
  
  
  1.9       +3 -3      
xml-cocoon2/src/java/org/apache/cocoon/environment/http/HttpContext.java
  
  Index: HttpContext.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/http/HttpContext.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- HttpContext.java  21 Nov 2002 18:18:49 -0000      1.8
  +++ HttpContext.java  5 Dec 2002 14:21:36 -0000       1.9
  @@ -66,10 +66,10 @@
    * @version CVS $Id$
    */
   
  -public class HttpContext implements Context {
  +public final class HttpContext implements Context {
   
       /** The ServletContext */
  -    private ServletContext servletContext = null;
  +    private final ServletContext servletContext;
   
       /**
        * Constructs a HttpContext object from a ServletContext object
  
  
  
  1.5       +3 -4      
xml-cocoon2/src/java/org/apache/cocoon/environment/http/HttpResponse.java
  
  Index: HttpResponse.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/http/HttpResponse.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- HttpResponse.java 22 Feb 2002 07:03:50 -0000      1.4
  +++ HttpResponse.java 5 Dec 2002 14:21:36 -0000       1.5
  @@ -68,16 +68,15 @@
    * @version CVS $Id$
    */
   
  -public class HttpResponse implements Response {
  +public final class HttpResponse implements Response {
   
       /** The real HttpServletResponse object */
  -    private HttpServletResponse res = null;
  +    private final HttpServletResponse res;
   
       /**
        * Creates a HttpServletResponse based on a real HttpServletResponse object
        */
       protected HttpResponse (HttpServletResponse res) {
  -        super ();
           this.res = res;
       }
   
  
  
  
  1.6       +2 -2      
xml-cocoon2/src/java/org/apache/cocoon/environment/ForwardRedirector.java
  
  Index: ForwardRedirector.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/ForwardRedirector.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ForwardRedirector.java    31 Jul 2002 13:13:27 -0000      1.5
  +++ ForwardRedirector.java    5 Dec 2002 14:21:36 -0000       1.6
  @@ -231,7 +231,7 @@
        * Local extension of EnvironmentWrapper to propagate otherwise blocked
        * methods to the actual environment.
        */
  -    private class ForwardEnvironmentWrapper extends EnvironmentWrapper {
  +    private final class ForwardEnvironmentWrapper extends EnvironmentWrapper {
   
           public ForwardEnvironmentWrapper(Environment env,
                                 String      requestURI,
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to