Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 40469 invoked by uid 500); 5 Jun 2003 16:34:00 -0000 Mailing-List: contact cocoon-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: cocoon-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cocoon-cvs@xml.apache.org Received: (qmail 40458 invoked by uid 500); 5 Jun 2003 16:34:00 -0000 Delivered-To: apmail-cocoon-2.1-cvs@apache.org Received: (qmail 40455 invoked from network); 5 Jun 2003 16:34:00 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 5 Jun 2003 16:34:00 -0000 Received: (qmail 80041 invoked by uid 1318); 5 Jun 2003 16:33:59 -0000 Date: 5 Jun 2003 16:33:59 -0000 Message-ID: <20030605163359.80040.qmail@icarus.apache.org> From: sylvain@apache.org To: cocoon-2.1-cvs@apache.org Subject: cvs commit: cocoon-2.1/src/java/org/apache/cocoon/servlet ParanoidCocoonServlet.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N sylvain 2003/06/05 09:33:59 Modified: src/java/org/apache/cocoon/servlet ParanoidCocoonServlet.java Log: New "servlet-class" parameter to load any servlet Revision Changes Path 1.3 +17 -10 cocoon-2.1/src/java/org/apache/cocoon/servlet/ParanoidCocoonServlet.java Index: ParanoidCocoonServlet.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/servlet/ParanoidCocoonServlet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ParanoidCocoonServlet.java 3 Jun 2003 13:25:42 -0000 1.2 +++ ParanoidCocoonServlet.java 5 Jun 2003 16:33:59 -0000 1.3 @@ -66,12 +66,14 @@ import javax.servlet.http.HttpServlet; /** - * This is the entry point for Cocoon execution as an HTTP Servlet. - * It also creates a buffer by loading the whole servlet inside a ClassLoader. - * It has been changed to extend CocoonServlet so that it is - * easier to add and change functionality between the two servlets. - * The only real differences are the ClassLoader and instantiating Cocoon inside - * of it. + * This servlet builds a classloading sandbox and runs another servlet inside that + * sandbox. The purpose is to shield the libraries and classes shipped with the web + * application from any other classes with the same name that may exist in the system, + * such as Xerces and Xalan versions included in JDK 1.4. + *

+ * This servlet propagates all initialisation parameters to the sandboxed servlet, and + * accept only one additional parameter, servlet-class, which defined the + * sandboxed servlet class. The default is {@link CocoonServlet}. * * @author Berin Loritsch * @author Sylvain Wallez @@ -83,7 +85,7 @@ /** * The name of the actual servlet class. */ - public static final String SERVLET_CLASS = "org.apache.cocoon.servlet.CocoonServlet"; + public static final String DEFAULT_SERVLET_CLASS = "org.apache.cocoon.servlet.CocoonServlet"; private Servlet servlet; @@ -96,14 +98,19 @@ // Create the classloader in which we will load the servlet this.classloader = getClassLoader(this.getContextDir()); + String servletName = config.getInitParameter("servlet-class"); + if (servletName == null) { + servletName = DEFAULT_SERVLET_CLASS; + } + // Create the servlet try { - Class servletClass = this.classloader.loadClass(SERVLET_CLASS); + Class servletClass = this.classloader.loadClass(servletName); this.servlet = (Servlet)servletClass.newInstance(); } catch(Exception e) { - throw new ServletException("Cannot load servlet " + SERVLET_CLASS, e); + throw new ServletException("Cannot load servlet " + servletName, e); } // Always set the context classloader. JAXP uses it to find a ParserFactory,