org.apache.cocoon.servlet
Class ParanoidCocoonServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.apache.cocoon.servlet.ParanoidCocoonServlet
All Implemented Interfaces:
Serializable, Servlet, ServletConfig
Direct Known Subclasses:
BootstrapServlet

public class ParanoidCocoonServlet
extends HttpServlet

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 accepts the parameters servlet-class and paranoid-classpath.

Version:
CVS $Id: ParanoidCocoonServlet.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Berin Loritsch, Sylvain Wallez, Torsten Curdt
See Also:
Serialized Form

Field Summary
protected  ClassLoader classloader
           
protected static String CONTEXT_PREFIX
           
static String DEFAULT_SERVLET_CLASS
          The name of the actual servlet class.
protected static String FILE_PREFIX
           
protected  Servlet servlet
           
 
Constructor Summary
ParanoidCocoonServlet()
           
 
Method Summary
protected  ClassLoader createClassLoader(String className, URL[] classPath)
           
 void destroy()
          Destroy the actual servlet
protected  ClassLoader getClassLoader(File contextDir)
          Deprecated.  
protected  ClassLoader getClassLoader(String externalClasspath, File contextDir)
          Deprecated.  
protected  URL[] getClassPath(File contextDir)
           
protected  URL[] getClassPath(String externalClasspath, File contextDir)
           
protected  File getContextDir()
          Get the web application context directory.
 void init(ServletConfig config)
           
protected  void initServlet()
          Initialize the wrapped servlet.
 void service(ServletRequest request, ServletResponse response)
          Service the request by delegating the call to the real servlet
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SERVLET_CLASS

public static final String DEFAULT_SERVLET_CLASS
The name of the actual servlet class.

See Also:
Constant Field Values

CONTEXT_PREFIX

protected static final String CONTEXT_PREFIX
See Also:
Constant Field Values

FILE_PREFIX

protected static final String FILE_PREFIX
See Also:
Constant Field Values

servlet

protected Servlet servlet

classloader

protected ClassLoader classloader
Constructor Detail

ParanoidCocoonServlet

public ParanoidCocoonServlet()
Method Detail

init

public void init(ServletConfig config)
          throws ServletException
Specified by:
init in interface Servlet
Overrides:
init in class GenericServlet
Throws:
ServletException

initServlet

protected void initServlet()
                    throws ServletException
Initialize the wrapped servlet. Subclasses (see BootstrapServlet change the ServletConfig given to the servlet.

Throws:
ServletException

getContextDir

protected File getContextDir()
                      throws ServletException
Get the web application context directory.

Returns:
the context dir
Throws:
ServletException

getClassPath

protected URL[] getClassPath(File contextDir)
                      throws ServletException
Throws:
ServletException

getClassPath

protected URL[] getClassPath(String externalClasspath,
                             File contextDir)
                      throws ServletException
Throws:
ServletException

createClassLoader

protected ClassLoader createClassLoader(String className,
                                        URL[] classPath)
                                 throws ServletException
Throws:
ServletException

getClassLoader

protected ClassLoader getClassLoader(File contextDir)
                              throws ServletException
Deprecated. 

Get the classloader that will be used to create the actual servlet. Its classpath is defined by the WEB-INF/classes and WEB-INF/lib directories in the context dir.

Throws:
ServletException

getClassLoader

protected ClassLoader getClassLoader(String externalClasspath,
                                     File contextDir)
                              throws ServletException
Deprecated. 

Get the classloader that will be used to create the actual servlet. Its classpath is defined by an external file.

Throws:
ServletException

service

public void service(ServletRequest request,
                    ServletResponse response)
             throws ServletException,
                    IOException
Service the request by delegating the call to the real servlet

Specified by:
service in interface Servlet
Overrides:
service in class HttpServlet
Throws:
ServletException
IOException

destroy

public void destroy()
Destroy the actual servlet

Specified by:
destroy in interface Servlet
Overrides:
destroy in class GenericServlet


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.