cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/servlet CocoonServlet.java BootstrapServlet.java
Date Thu, 11 Apr 2002 13:44:27 GMT
sylvain     02/04/11 06:44:27

  Modified:    src/java/org/apache/cocoon/servlet Tag: cocoon_2_0_3_branch
                        CocoonServlet.java BootstrapServlet.java
  Log:
  - BootstrapServlet incorrectly handled servlet config attributes
  - rename "context-dir" parameter in BootstrapServlet to "context-directory" for consistency
with other parameters
  - fix handling of absolute paths for the work-directory parameter
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.19.2.1  +11 -2     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
  retrieving revision 1.19.2.1
  diff -u -r1.19 -r1.19.2.1
  --- CocoonServlet.java	24 Mar 2002 21:56:35 -0000	1.19
  +++ CocoonServlet.java	11 Apr 2002 13:44:27 -0000	1.19.2.1
  @@ -118,7 +118,7 @@
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
    * @author <a href="mailto:leo.sutic@inspireinfrastructure.com">Leo Sutic</a>
  - * @version CVS $Id: CocoonServlet.java,v 1.19 2002/03/24 21:56:35 sylvain Exp $
  + * @version CVS $Id: CocoonServlet.java,v 1.19.2.1 2002/04/11 13:44:27 sylvain Exp $
    */
   public class CocoonServlet extends HttpServlet {
   
  @@ -227,9 +227,18 @@
           final String workDirParam = conf.getInitParameter("work-directory");
           if ((workDirParam != null) && (!workDirParam.trim().equals(""))) {
               if (this.servletContextPath == null) {
  +                // No context path : consider work-directory as absolute
                   this.workDir = new File(workDirParam);
               } else {
  -                this.workDir = IOUtils.createFile( new File(servletContextPath) , workDirParam);
  +                // Context path exists : is work-directory absolute ?
  +                File workDirParamFile = new File(workDirParam);
  +                if (workDirParamFile.isAbsolute()) {
  +                    // Yes : keep it as is
  +                    this.workDir = workDirParamFile;
  +                } else {
  +                    // No : consider it relative to context path
  +                    this.workDir = new File(servletContextPath , workDirParam);
  +                }
               }
               this.workDir.mkdirs();
           } else {
  
  
  
  1.2.2.1   +22 -16    xml-cocoon2/src/java/org/apache/cocoon/servlet/BootstrapServlet.java
  
  Index: BootstrapServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/servlet/BootstrapServlet.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- BootstrapServlet.java	23 Mar 2002 19:52:02 -0000	1.2
  +++ BootstrapServlet.java	11 Apr 2002 13:44:27 -0000	1.2.2.1
  @@ -83,7 +83,7 @@
    * </ul>
    *
    * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
  - * @version CVS $Id: BootstrapServlet.java,v 1.2 2002/03/23 19:52:02 sylvain Exp $
  + * @version CVS $Id: BootstrapServlet.java,v 1.2.2.1 2002/04/11 13:44:27 sylvain Exp $
    */
   
   public class BootstrapServlet extends HttpServlet {
  @@ -100,17 +100,21 @@
       protected ServletContext context;
       
       public void init(ServletConfig config) throws ServletException {
  -        super.init(config);
  -        
           this.context = config.getServletContext();
           
           this.context.log("getRealPath(\"/\") = " + context.getRealPath("/"));
   
  -        String contextDirParam = getInitParameter("context-dir");
  +        String contextDirParam = config.getInitParameter("context-directory");
           if (contextDirParam == null) {
  -            String msg = "The 'context-dir' parameter must be set to the root of the servlet
context";
  -            this.context.log(msg);
  -            throw new ServletException(msg);
  +            // Check old form, not consistent with other parameter names
  +            contextDirParam = config.getInitParameter("context-dir");
  +            if (contextDirParam == null) {
  +                String msg = "The 'context-directory' parameter must be set to the root
of the servlet context";
  +                this.context.log(msg);
  +                throw new ServletException(msg);
  +            } else {
  +                this.context.log("Parameter 'context-dir' is deprecated - use 'context-directory'");
  +            }
           }
           
           // Ensure context dir doesn't end with a "/" (servlet spec says that paths for
  @@ -151,7 +155,9 @@
           Thread.currentThread().setContextClassLoader(this.classloader);
           
           ServletContext newContext = new ContextWrapper(context, contextDirParam);
  -        ServletConfig newConfig = new SimpleConfig(config.getServletName(), newContext);
  +        ServletConfig newConfig = new ConfigWrapper(config, newContext);
  +        
  +        super.init(newConfig);
           
           // Inlitialize the actual servlet
           this.servlet.init(newConfig);
  @@ -220,26 +226,26 @@
       //-------------------------------------------------------------------------
       /**
        * Implementation of <code>ServletConfig</code> passed to the actual servlet.
  -     * It delegates calls to the provided <code>ServletContext</code>.
  +     * It wraps the original config object and returns the new context.
        */
  -    public static class SimpleConfig implements ServletConfig {
  -        String name;
  +    public static class ConfigWrapper implements ServletConfig {
  +        ServletConfig config;
           ServletContext context;
           
           /**
            * Builds a <code>ServletConfig</code> using a servlet name and
            * a <code>ServletContext</code>.
            */
  -        public SimpleConfig(String name, ServletContext context) {
  -            this.name = name;
  +        public ConfigWrapper(ServletConfig config, ServletContext context) {
  +            this.config = config;
               this.context = context;
           }
           public String getServletName() {
  -            return this.name;
  +            return config.getServletName();
           }
           
           public Enumeration getInitParameterNames() {
  -            return this.context.getInitParameterNames();
  +            return this.config.getInitParameterNames();
           }
           
           public ServletContext getServletContext() {
  @@ -247,7 +253,7 @@
           }
           
           public String getInitParameter(String name) {
  -            return context.getInitParameter(name);
  +            return config.getInitParameter(name);
           }
       }
   
  
  
  

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