You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by di...@apache.org on 2001/05/22 21:23:21 UTC

cvs commit: xml-cocoon2/src/org/apache/cocoon/sitemap Handler.java

dims        01/05/22 12:23:20

  Modified:    lib      xalan-2.0.1.jar
               src/org/apache/cocoon/servlet CocoonServlet.java
                        ParanoidCocoonServlet.java
               src/org/apache/cocoon/sitemap Handler.java
  Log:
  Get Cocoon working out of the box in ServletExec 3.1. Just drop the
  cocoon.war in \servletexec\webapps\default directory and restart the
  server(s). You do not need to make any changes (cocoon.xconf etc), just
  use the everything from cvs as-is.
  
  Revision  Changes    Path
  1.3       +2348 -2496xml-cocoon2/lib/xalan-2.0.1.jar
  
  	<<Binary file>>
  
  
  1.3       +34 -12    xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CocoonServlet.java	2001/05/15 20:27:51	1.2
  +++ CocoonServlet.java	2001/05/22 19:23:05	1.3
  @@ -57,7 +57,7 @@
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
    * @author <a href="mailto:nicolaken@supereva.it">Nicola Ken Barozzi</a> Aisa
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2001/05/15 20:27:51 $
  + * @version CVS $Revision: 1.3 $ $Date: 2001/05/22 19:23:05 $
    */
   
   public class CocoonServlet extends HttpServlet {
  @@ -80,6 +80,7 @@
       private File uploadDir;
   
       protected ServletContext servletContext;
  +    protected RepositoryClassLoader classLoader;
   
       /**
        * Initialize this <code>CocoonServlet</code> instance.  You will
  @@ -98,18 +99,18 @@
   
           super.init(conf);
   
  +        classLoader = buildInitClassLoader();
  +
           /* HACK for reducing class loader problems.                                     */
           /* example: xalan extensions fail if someone adds xalan jars in tomcat3.2.1/lib */
           try {
  -            if(Thread.currentThread().getContextClassLoader() != this.getClass().getClassLoader())
  -                Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
  +            Thread.currentThread().setContextClassLoader(classLoader);
           } catch (Exception e){}
   
  -        ClassLoader classloader = buildInitClassLoader();
           this.servletContext = conf.getServletContext();
   
  -        ClassUtils.setClassLoader(classloader);
  -        this.appContext.put(Constants.CONTEXT_CLASS_LOADER, classloader);
  +        ClassUtils.setClassLoader(classLoader);
  +        this.appContext.put(Constants.CONTEXT_CLASS_LOADER, classLoader);
   
           this.appContext.put(Constants.CONTEXT_ENVIRONMENT_CONTEXT, new HttpContext(this.servletContext));
           this.initLogger(this.servletContext);
  @@ -142,7 +143,8 @@
           this.appContext.put(Constants.CONTEXT_CONFIG_URL,
                   this.getConfigFile(conf.getInitParameter("configurations"), this.servletContext));
   
  -        this.appContext.put(Constants.CONTEXT_ROOT_PATH, this.servletContext.getRealPath("/"));
  +        if(this.servletContext.getRealPath("/") != null)
  +            this.appContext.put(Constants.CONTEXT_ROOT_PATH, this.servletContext.getRealPath("/"));
   
           // get allow reload parameter, default is true
           String value = conf.getInitParameter("allow-reload");
  @@ -151,11 +153,11 @@
           this.createCocoon();
       }
   
  -    /**
  -     * get the classloader to use for Cocoon instantiation
  -     */
  -     protected ClassLoader buildInitClassLoader() {
  -        return this.getClass().getClassLoader();
  +     /**
  +      * get the classloader to use for Cocoon instantiation
  +      */
  +     protected RepositoryClassLoader buildInitClassLoader() {
  +         return new RepositoryClassLoader(new URL[] {}, this.getClass().getClassLoader());
        }
   
       /**
  @@ -177,10 +179,19 @@
        protected String getClassPath(final ServletContext context)
        throws ServletException {
           StringBuffer buildClassPath = new StringBuffer();
  +
  +        if(context.getRealPath("/")==null)
  +            return "";
  +
           String classDir = context.getRealPath("/WEB-INF/classes");
           File root = new File(context.getRealPath("/WEB-INF/lib"));
   
           buildClassPath.append(classDir);
  +        try {
  +            classLoader.addDirectory(new File(classDir));
  +        } catch (Exception e) {
  +            log.debug("Could not add directory" + classDir, e);
  +        }
   
           if (root.isDirectory()) {
               File[] libraries = root.listFiles();
  @@ -188,6 +199,11 @@
               for (int i = 0; i < libraries.length; i++) {
                   buildClassPath.append(File.pathSeparatorChar)
                                 .append(IOUtils.getFullFilename(libraries[i]));
  +                try {
  +                    classLoader.addDirectory(libraries[i]);
  +                } catch (Exception e) {
  +                    log.debug("Could not add file" + IOUtils.getFullFilename(libraries[i]));
  +                }
               }
           }
   
  @@ -388,6 +404,12 @@
        */
       public void service(HttpServletRequest req, HttpServletResponse res)
       throws ServletException, IOException {
  +
  +        /* HACK for reducing class loader problems.                                     */
  +        /* example: xalan extensions fail if someone adds xalan jars in tomcat3.2.1/lib */
  +        try {
  +            Thread.currentThread().setContextClassLoader(classLoader);
  +        } catch (Exception e){}
   
           // This is more scalable
           long start = new Date().getTime();
  
  
  
  1.2       +3 -17     xml-cocoon2/src/org/apache/cocoon/servlet/ParanoidCocoonServlet.java
  
  Index: ParanoidCocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/servlet/ParanoidCocoonServlet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ParanoidCocoonServlet.java	2001/05/09 20:49:37	1.1
  +++ ParanoidCocoonServlet.java	2001/05/22 19:23:07	1.2
  @@ -17,7 +17,6 @@
   import javax.servlet.ServletException;
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.cocoon.Constants;
  -import org.apache.cocoon.components.classloader.RepositoryClassLoader;
   import org.apache.cocoon.util.IOUtils;
   
   /**
  @@ -29,18 +28,11 @@
    * of it.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2001/05/09 20:49:37 $
  + * @version CVS $Revision: 1.2 $ $Date: 2001/05/22 19:23:07 $
    */
   
   public class ParanoidCocoonServlet extends CocoonServlet {
   
  -     /**
  -      * get the classloader to use for Cocoon instantiation
  -      */
  -     protected ClassLoader buildInitClassLoader() {
  -         return new RepositoryClassLoader(new URL[] {}, this.getClass().getClassLoader());
  -     }
  -
       /**
        * This builds the important ClassPath used by this Servlet.  It
        * does so in a Servlet Engine neutral way.  It uses the
  @@ -59,12 +51,6 @@
        */
        protected String getClassPath(final ServletContext context)
        throws ServletException {
  -        RepositoryClassLoader classloader = null;
  -        try {
  -            classloader = (RepositoryClassLoader) this.appContext.get(Constants.CONTEXT_CLASS_LOADER);
  -        } catch (ContextException e) {
  -            log.debug("ContextException in getClassPath", e);
  -        }
   
           StringBuffer buildClassPath = new StringBuffer();
           String classDirPath = getInitParameter("class-dir");
  @@ -85,7 +71,7 @@
           }
   
           try {
  -            classloader.addDirectory(new File(classDir));
  +            classLoader.addDirectory(new File(classDir));
           } catch (Exception e) {
               log.debug("Could not add directory" + classDir, e);
           }
  @@ -100,7 +86,7 @@
                                 .append(IOUtils.getFullFilename(libraries[i]));
   
                   try {
  -                    classloader.addDirectory(libraries[i]);
  +                    classLoader.addDirectory(libraries[i]);
                   } catch (Exception e) {
                       log.debug("Could not add file" + IOUtils.getFullFilename(libraries[i]));
                   }
  
  
  
  1.3       +2 -2      xml-cocoon2/src/org/apache/cocoon/sitemap/Handler.java
  
  Index: Handler.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/sitemap/Handler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Handler.java	2001/05/22 14:45:20	1.2
  +++ Handler.java	2001/05/22 19:23:16	1.3
  @@ -39,7 +39,7 @@
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
    * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2001/05/22 14:45:20 $
  + * @version CVS $Revision: 1.3 $ $Date: 2001/05/22 19:23:16 $
    */
   public class Handler extends AbstractLoggable implements Runnable, Configurable, Composable, Contextualizable, Processor, Disposable {
       private Context context;
  @@ -138,7 +138,7 @@
               /* HACK for reducing class loader problems.                                     */
               /* example: xalan extensions fail if someone adds xalan jars in tomcat3.2.1/lib */
               try {
  -                regeneration.setContextClassLoader(this.getClass().getClassLoader());
  +                regeneration.setContextClassLoader(Thread.currentThread().getContextClassLoader());
               } catch (Exception e){}
               this.environment = environment;
   
  
  
  

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