Save This Page
Home » cocoon-2.1.11-src » org.apache » cocoon » servlet » [javadoc | source]
public class: CocoonServlet [javadoc | source]

All Implemented Interfaces:
    Serializable, Servlet, ServletConfig

This is the entry point for Cocoon execution as an HTTP Servlet.
Field Summary
public static final  String CONTEXT_SERVLET_CONFIG    Application Context Key for the servlet configuration
    since: 2.1.3 -
protected static final  String PROCESSED_BY     
static final  float SECOND     
static final  float MINUTE     
static final  float HOUR     
protected  long creationTime    The time the cocoon instance was created 
protected  Cocoon cocoon    The Cocoon instance 
protected  Exception exception    Holds exception happened during initialization (if any) 
protected  DefaultContext appContext    Avalon application context 
protected static final  boolean ALLOW_RELOAD    Default value for #allowReload parameter (false) 
protected  boolean allowReload    Allow reloading of cocoon by specifying the cocoon-reload=true parameter with a request 
protected  boolean showTime    Allow adding processing time to the response 
protected  boolean hiddenShowTime    If true, processing time will be added as an HTML comment 
protected  ServletContext servletContext     
protected  ClassLoader classLoader    The classloader that will be set as the context classloader if init-classloader is true 
protected  boolean initClassLoader     
protected  String forceLoadParameter     
protected  String forceSystemProperty     
protected  String servletContextPath    This is the path to the servlet context (or the result of calling getRealPath('/') on the ServletContext. Note, that this can be null. 
protected  String servletContextURL    This is the url to the servlet context directory 
protected  RequestFactory requestFactory    The RequestFactory is responsible for wrapping multipart-encoded forms and for handing the file payload of incoming requests 
Method from org.apache.cocoon.servlet.CocoonServlet Summary:
addClassLoaderDirectory,   addClassLoaderURL,   createCocoon,   destroy,   disposeCocoon,   getClassPath,   getEnvironment,   getExtraClassPath,   getInitParameter,   getInitParameter,   getInitParameterAsBoolean,   getInitParameterAsInteger,   getLogger,   getLoggerManager,   getParentComponentManager,   init,   initLogger,   manageException,   service,   updateEnvironment
Methods from javax.servlet.http.HttpServlet:
Methods from javax.servlet.GenericServlet:
destroy,   getInitParameter,   getInitParameterNames,   getServletConfig,   getServletContext,   getServletInfo,   getServletName,   init,   init,   log,   log,   service
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.cocoon.servlet.CocoonServlet Detail:
 protected  void addClassLoaderDirectory(String dir) 
 protected  void addClassLoaderURL(URL URL) 
 protected synchronized  void createCocoon() throws ServletException 
    Creates the Cocoon object and handles exception handling.
 public  void destroy() 
    Dispose Cocoon when servlet is destroyed
 protected final  void disposeCocoon() 
    Destroy Cocoon
 protected String getClassPath() throws ServletException 
    This builds the important ClassPath used by this Servlet. It does so in a Servlet Engine neutral way. It uses the ServletContext's getRealPath method to get the Servlet 2.2 identified classes and lib directories. It iterates in alphabetical order through every file in the lib directory and adds it to the classpath. Also, we add the files to the ClassLoader for the Cocoon system. In order to protect ourselves from skitzofrantic classloaders, we need to work with a known one. We need to get this to work properly when Cocoon is in a war.
 protected Environment getEnvironment(String uri,
    HttpServletRequest req,
    HttpServletResponse res) throws Exception 
    Create the environment for the request
 protected String getExtraClassPath() throws ServletException 
    Retreives the "extra-classpath" attribute, that needs to be added to the class path.
 public String getInitParameter(String name) 
    Get an initialisation parameter. The value is trimmed, and null is returned if the trimmed value is empty.
 protected String getInitParameter(String name,
    String defaultValue) 
    Convenience method to access servlet parameters
 protected boolean getInitParameterAsBoolean(String name,
    boolean defaultValue) 
    Convenience method to access boolean servlet parameters
 protected int getInitParameterAsInteger(String name,
    int defaultValue) 
 protected Logger getLogger() 
 protected LoggerManager getLoggerManager() 
 protected synchronized ComponentManager getParentComponentManager() 
    Instatiates the parent component manager, as specified in the parent-component-manager init parameter. If none is specified, the method returns null.
 public  void init(ServletConfig conf) throws ServletException 
    Initialize this CocoonServlet instance. You will notice that I have broken the init into sub methods to make it easier to maintain (BL). The context is passed to a couple of the subroutines. This is also because it is better to explicitly pass variables than implicitely. It is both more maintainable, and more elegant.
 protected  void initLogger() 
    Set up the log level and path. The default log level is Priority.ERROR, although it can be overwritten by the parameter "log-level". The log system goes to both a file and the Servlet container's log system. Only messages that are Priority.ERROR and above go to the servlet context. The log messages can be as restrictive (Priority.FATAL_ERROR and above) or as liberal (Priority.DEBUG and above) as you want that get routed to the file.
 protected  void manageException(HttpServletRequest req,
    HttpServletResponse res,
    Environment env,
    String uri,
    int errorStatus,
    String title,
    String message,
    String description,
    Exception e) throws IOException 
 public  void service(HttpServletRequest req,
    HttpServletResponse res) throws IOException, ServletException 
    Process the specified HttpServletRequest producing output on the specified HttpServletResponse.
 protected  void updateEnvironment() throws ServletException 
    Method to update the environment before Cocoon instances are created. This is also useful if you wish to customize any of the 'protected' variables from this class before a Cocoon instance is built in a derivative of this class (eg. Cocoon Context).