cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/servlet CocoonServlet.java
Date Tue, 29 Oct 2002 04:48:59 GMT
vgritsenko    2002/10/28 20:48:59

  Modified:    .        Tag: cocoon_2_0_3_branch changes.xml
               src/java/org/apache/cocoon/components/request Tag:
                        cocoon_2_0_3_branch
                        MaybeUploadRequestFactoryImpl.java
                        RequestFactory.java
               src/java/org/apache/cocoon/environment/http Tag:
                        cocoon_2_0_3_branch HttpEnvironment.java
                        HttpRequest.java
               src/java/org/apache/cocoon/servlet Tag: cocoon_2_0_3_branch
                        CocoonServlet.java
  Log:
  Remove the static factory variable in RequestFactory, and instead
  pass it to the HttpRequest via the environment.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.138.2.63 +5 -1      xml-cocoon2/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/changes.xml,v
  retrieving revision 1.138.2.62
  retrieving revision 1.138.2.63
  diff -u -r1.138.2.62 -r1.138.2.63
  --- changes.xml	23 Oct 2002 04:20:43 -0000	1.138.2.62
  +++ changes.xml	29 Oct 2002 04:48:58 -0000	1.138.2.63
  @@ -39,6 +39,10 @@
    </devs>
   
    <release version="@version@" date="@date@">
  +  <action dev="VG" type="fix" fixes-bug="13643" due-to="Leo Sutic" due-to-email="leo.sutic@inspireinfrastructure.com">
  +    Remove the static factory variable in RequestFactory, and instead 
  +    pass it to the HttpRequest via the environment.
  +  </action>
     <action dev="VG" type="update">
       ReadDOMSessionTransformer now can work with any types of object
       (same mechanism as in &lt;xsp:expr&gt; now used). Configuration
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.2   +10 -10    xml-cocoon2/src/java/org/apache/cocoon/components/request/MaybeUploadRequestFactoryImpl.java
  
  Index: MaybeUploadRequestFactoryImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/request/MaybeUploadRequestFactoryImpl.java,v
  retrieving revision 1.2.2.1
  retrieving revision 1.2.2.2
  diff -u -r1.2.2.1 -r1.2.2.2
  --- MaybeUploadRequestFactoryImpl.java	15 Jul 2002 14:10:35 -0000	1.2.2.1
  +++ MaybeUploadRequestFactoryImpl.java	29 Oct 2002 04:48:58 -0000	1.2.2.2
  @@ -59,14 +59,13 @@
   import java.util.Vector;
   
   /**
  - *
    * Extends the {@link RequestFactory} class
    *
    * @author <a href="mailto:dims@apache.org">Davanum Srinivas</a>
    * @version CVS $Id$
    */
  -
   public final class MaybeUploadRequestFactoryImpl extends RequestFactory {
  +
       /**
        * Return a wrapped request object
        */
  @@ -87,13 +86,14 @@
               int oldInterval = -1;
               HttpSession session = null;
               try {
  -                 // Change the session timeout to infinite whilst the upload takes place,
  -                 // to prevent a timeout occuring during a long upload.
  -                 session = req.getSession(false);
  -                 if ( null != session) {
  -                     oldInterval = session.getMaxInactiveInterval();
  -                     session.setMaxInactiveInterval( -1 );
  -                 }
  +                // Change the session timeout to infinite whilst the upload takes place,
  +                // to prevent a timeout occuring during a long upload.
  +                session = req.getSession(false);
  +                if ( null != session) {
  +                    oldInterval = session.getMaxInactiveInterval();
  +                    session.setMaxInactiveInterval( -1 );
  +                }
  +
                   req = new MaybeUploadRequestWrapperEx(request,
                                            saveUploadedFilesToDisk,
                                            uploadDirectory,
  
  
  
  1.1.2.1   +14 -12    xml-cocoon2/src/java/org/apache/cocoon/components/request/RequestFactory.java
  
  Index: RequestFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/request/RequestFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- RequestFactory.java	24 Feb 2002 11:10:58 -0000	1.1
  +++ RequestFactory.java	29 Oct 2002 04:48:58 -0000	1.1.2.1
  @@ -62,27 +62,28 @@
    * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
    * @version CVS $Id$
    */
  -public abstract class   RequestFactory
  -        implements Component {
  +public abstract class RequestFactory implements Component {
   
  -    static private RequestFactory factory;
  -
  -    public static synchronized RequestFactory getRequestFactory(String className) {
  -        if(factory != null)
  -            return factory;
  +    public static RequestFactory getRequestFactory(String className) {
  +        RequestFactory factory = null;
           try {
               ClassLoader loader = Thread.currentThread().getContextClassLoader();
               Class clazz = loader.loadClass(className);
               factory = (RequestFactory)clazz.newInstance();
  -        } catch (Throwable t){}
  +        } catch (Throwable t) {
  +            // FIXME (VG): Is it Ok to ignore all exceptions?
  +        }
           if(factory == null) {
               try {
                   Class clazz = Class.forName(className);
                   factory = (RequestFactory)clazz.newInstance();
  -            } catch (Throwable t){}
  +            } catch (Throwable t) {
  +                // FIXME (VG): Is it Ok to ignore all exceptions?
  +            }
           }
  -        if(factory == null)
  +        if (factory == null) {
               factory = new SimpleRequestFactoryImpl();
  +        }
           return factory;
       }
   
  @@ -95,8 +96,9 @@
                                                   boolean allowOverwrite,
                                                   boolean silentlyRename,
                                                   int maxUploadSize);
  +
       /**
        * Implementation of the get method
        */
       public abstract Object get(HttpServletRequest request, String name);
  -}
  \ No newline at end of file
  +}
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.12.2.3  +6 -4      xml-cocoon2/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
  
  Index: HttpEnvironment.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/http/HttpEnvironment.java,v
  retrieving revision 1.12.2.2
  retrieving revision 1.12.2.3
  diff -u -r1.12.2.2 -r1.12.2.3
  --- HttpEnvironment.java	23 Sep 2002 12:16:53 -0000	1.12.2.2
  +++ HttpEnvironment.java	29 Oct 2002 04:48:59 -0000	1.12.2.3
  @@ -51,6 +51,7 @@
   package org.apache.cocoon.environment.http;
   
   import org.apache.cocoon.Constants;
  +import org.apache.cocoon.components.request.RequestFactory;
   import org.apache.cocoon.environment.AbstractEnvironment;
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Redirector;
  @@ -105,14 +106,15 @@
                               ServletContext servletContext,
                               HttpContext context,
                               String containerEncoding,
  -                            String defaultFormEncoding)
  +                            String defaultFormEncoding,
  +                            RequestFactory requestFactory)
        throws MalformedURLException, IOException {
           super(uri, req.getParameter(Constants.VIEW_PARAM), rootURL, extractAction(req));
   
  -        this.request = new HttpRequest (req, this);
  +        this.request = new HttpRequest(req, this, requestFactory);
           this.request.setCharacterEncoding(defaultFormEncoding);
           this.request.setContainerEncoding(containerEncoding);
  -        this.response = new HttpResponse (res);
  +        this.response = new HttpResponse(res);
           this.webcontext = context;
           this.outputStream = response.getOutputStream();
           this.objectModel.put(ObjectModelHelper.REQUEST_OBJECT, this.request);
  
  
  
  1.6.2.3   +7 -4      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.6.2.2
  retrieving revision 1.6.2.3
  diff -u -r1.6.2.2 -r1.6.2.3
  --- HttpRequest.java	15 Jul 2002 14:42:49 -0000	1.6.2.2
  +++ HttpRequest.java	29 Oct 2002 04:48:59 -0000	1.6.2.3
  @@ -83,20 +83,23 @@
   
       /** The default form encoding of the servlet container */
       private String container_encoding = null;
  +    
  +    private final RequestFactory requestFactory;
   
       /**
        * Creates a HttpServletRequest based on a real HttpServletRequest object
        */
  -    protected HttpRequest (HttpServletRequest req, HttpEnvironment env) {
  -        super ();
  +    protected HttpRequest(HttpServletRequest req, HttpEnvironment env, RequestFactory requestFactory)
{
  +        super();
           this.req = req;
           this.env = env;
  +        this.requestFactory = requestFactory;
       }
   
       /* The HttpServletRequest interface methods */
   
       public Object get(String name) {
  -        return RequestFactory.getRequestFactory(null).get(this.req, name);
  +        return requestFactory.get(this.req, name);
       }
   
       public String getAuthType() {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.19.2.13 +23 -19    xml-cocoon2/src/java/org/apache/cocoon/servlet/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/servlet/CocoonServlet.java,v
  retrieving revision 1.19.2.12
  retrieving revision 1.19.2.13
  diff -u -r1.19.2.12 -r1.19.2.13
  --- CocoonServlet.java	22 Oct 2002 04:01:58 -0000	1.19.2.12
  +++ CocoonServlet.java	29 Oct 2002 04:48:59 -0000	1.19.2.13
  @@ -161,7 +161,7 @@
       private String defaultFormEncoding;
   
       protected ServletContext servletContext;
  -    
  +
       /** The classloader that will be set as the context classloader if init-classloader
is true */
       protected ClassLoader classLoader = this.getClass().getClassLoader();
       protected boolean initClassLoader = false;
  @@ -190,6 +190,12 @@
        */
       protected URL servletContextURL;
   
  +
  +    /**
  +     * The requestFactory to use for incoming HTTP requests.
  +     */
  +    protected RequestFactory requestFactory;
  +
       /**
        * Initialize this <code>CocoonServlet</code> instance.  You will
        * notice that I have broken the init into sub methods to make it
  @@ -206,7 +212,7 @@
       throws ServletException {
   
           super.init(conf);
  -        
  +
           final String initClassLoaderParam = conf.getInitParameter("init-classloader");
           this.initClassLoader = "true".equalsIgnoreCase(initClassLoaderParam) ||
                                  "yes".equalsIgnoreCase(initClassLoaderParam);
  @@ -413,13 +419,14 @@
               }
           }
   
  -        requestFactoryClass = conf.getInitParameter("request-factory");
  +        this.requestFactoryClass = conf.getInitParameter("request-factory");
           if (requestFactoryClass == null) {
  -            requestFactoryClass = "org.apache.cocoon.components.request.MaybeUploadRequestFactoryImpl";
  +            requestFactoryClass = "org.apache.cocoon.components.request.MultipartRequestFactoryImpl";
               if (log.isDebugEnabled()) {
                   log.debug("request-factory was not set - defaulting to " + requestFactoryClass);
               }
           }
  +        this.requestFactory = RequestFactory.getRequestFactory(requestFactoryClass);
   
           this.containerEncoding = conf.getInitParameter("container-encoding");
           if (containerEncoding == null) {
  @@ -467,7 +474,7 @@
               this.disposeCocoon();
           }
       }
  -     
  +
       /**
        * Adds an URL to the classloader. Does nothing here, but is
        * overriden in {@link ParanoidCocoonServlet}.
  @@ -585,7 +592,7 @@
   
               Manifest mf = new Manifest(manifestURL.openStream());
               Attributes attr = mf.getMainAttributes();
  -            String libValue = (String)attr.getValue("Cocoon-Libs");
  +            String libValue = attr.getValue("Cocoon-Libs");
               if (libValue == null) {
                   this.log.fatalError("Unable to get 'Cocoon-Libs' attribute from the Manifest");
                   return null;
  @@ -723,11 +730,8 @@
        * be as restrictive (Priority.FATAL_ERROR and above) or as liberal
        * (Priority.DEBUG and above) as you want that get routed to the
        * file.
  -     *
  -     * @throws ServletException
        */
  -    private void initLogger()
  -    throws ServletException {
  +    private void initLogger() {
           String logLevel = getInitParameter("log-level");
           if (logLevel == null) {
               logLevel = "INFO";
  @@ -918,7 +922,7 @@
           // This is more scalable
           long start = System.currentTimeMillis();
           res.addHeader("X-Cocoon-Version", Constants.VERSION);
  -        HttpServletRequest request = RequestFactory.getRequestFactory(requestFactoryClass).getServletRequest(req,
  +        HttpServletRequest request = requestFactory.getServletRequest(req,
                                            CocoonServlet.SAVE_UPLOADED_FILES_TO_DISK,
                                            this.uploadDir,
                                            CocoonServlet.ALLOW_OVERWRITE,
  @@ -992,7 +996,7 @@
                       uri = uri.substring(1);
                   }
   
  -                Environment env = this.getEnvironment(URLDecoder.decode(uri), request,
res);
  +                Environment env = getEnvironment(URLDecoder.decode(uri), request, res);
   
                   // Initialize a fresh log context containing the object model : it
                   // will be used by the CocoonLogFormatter
  @@ -1063,7 +1067,7 @@
                       res.flushBuffer();
                   }
                   return;
  - 
  +
               } catch (ConnectionResetException cre) {
                   if (log.isDebugEnabled()) {
                       log.debug("The connection was reset", cre);
  @@ -1140,8 +1144,8 @@
        * Create the environment for the request
        */
       protected Environment getEnvironment(String uri,
  -                                       HttpServletRequest req,
  -                                       HttpServletResponse res)
  +                                         HttpServletRequest req,
  +                                         HttpServletResponse res)
       throws Exception {
           HttpEnvironment env;
   
  @@ -1156,7 +1160,8 @@
                                     this.servletContext,
                                     (HttpContext)this.appContext.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT),
                                     this.containerEncoding,
  -                                  formEncoding);
  +                                  formEncoding,
  +                                  this.requestFactory);
           env.setLogger(this.log);
           return env;
       }
  @@ -1265,8 +1270,7 @@
           this.appContext.put(Constants.CONTEXT_CLASSPATH, getClassPath());
        }
   
  -    private String processTime(long time) throws IOException {
  -
  +    private String processTime(long time) {
           StringBuffer out = new StringBuffer(PROCESSED_BY);
           if (time <= SECOND) {
               out.append(time);
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message