org.apache.cocoon.servlet
Class CocoonServlet

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--org.apache.cocoon.servlet.CocoonServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
ParanoidCocoonServlet

public class CocoonServlet
extends javax.servlet.http.HttpServlet

This is the entry point for Cocoon execution as an HTTP Servlet.

Version:
CVS $Id: CocoonServlet.java,v 1.19.2.14 2002/10/29 05:28:59 vgritsenko Exp $
Author:
Pierpaolo Fumagalli (Apache Software Foundation, Exoffice Technologies), Stefano Mazzocchi, Nicola Ken Barozzi, Berin Loritsch, Carsten Ziegeler, Leo Sutic
See Also:
Serialized Form

Field Summary
protected  boolean allowReload
          Allow reloading of cocoon by specifying the cocoon-reload parameter with a request
protected  org.apache.avalon.framework.context.DefaultContext appContext
           
protected  java.lang.ClassLoader classLoader
          The classloader that will be set as the context classloader if init-classloader is true
protected  Cocoon cocoon
          The Cocoon instance
protected  long creationTime
          The time the cocoon instance was created
protected  java.lang.Exception exception
           
protected  java.lang.String forceLoadParameter
           
protected  java.lang.String forceSystemProperty
           
protected  boolean hiddenShowTime
           
protected  boolean initClassLoader
           
protected  org.apache.log.Logger log
           
protected  org.apache.avalon.excalibur.logger.LogKitManager logKitManager
           
protected static java.lang.String PROCESSED_BY
           
protected  RequestFactory requestFactory
          The requestFactory to use for incoming HTTP requests.
protected  javax.servlet.ServletContext servletContext
           
protected  java.lang.String servletContextPath
          This is the path to the servlet context (or the result of calling getRealPath('/') on the ServletContext.
protected  java.net.URL servletContextURL
          This is the url to the servlet context directory
protected  boolean showTime
          Allow adding processing time to the response
 
Constructor Summary
CocoonServlet()
           
 
Method Summary
protected  void addClassLoaderDirectory(java.lang.String dir)
          Adds a directory to the classloader.
protected  void addClassLoaderURL(java.net.URL URL)
          Adds an URL to the classloader.
 void destroy()
          Dispose Cocoon when servlet is destroyed
protected  java.lang.String getClassPath()
          This builds the important ClassPath used by this Servlet.
protected  Environment getEnvironment(java.lang.String uri, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Create the environment for the request
protected  java.lang.String getExtraClassPath()
          Retreives the "extra-classpath" attribute, that needs to be added to the class path.
 void init(javax.servlet.ServletConfig conf)
          Initialize this CocoonServlet instance.
 void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Process the specified HttpServletRequest producing output on the specified HttpServletResponse.
protected  void updateEnvironment()
          Method to update the environment before Cocoon instances are created.
 
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

PROCESSED_BY

protected static final java.lang.String PROCESSED_BY

log

protected org.apache.log.Logger log

logKitManager

protected org.apache.avalon.excalibur.logger.LogKitManager logKitManager

creationTime

protected long creationTime
The time the cocoon instance was created

cocoon

protected Cocoon cocoon
The Cocoon instance

exception

protected java.lang.Exception exception

appContext

protected org.apache.avalon.framework.context.DefaultContext appContext

allowReload

protected boolean allowReload
Allow reloading of cocoon by specifying the cocoon-reload parameter with a request

showTime

protected boolean showTime
Allow adding processing time to the response

hiddenShowTime

protected boolean hiddenShowTime

servletContext

protected javax.servlet.ServletContext servletContext

classLoader

protected java.lang.ClassLoader classLoader
The classloader that will be set as the context classloader if init-classloader is true

initClassLoader

protected boolean initClassLoader

forceLoadParameter

protected java.lang.String forceLoadParameter

forceSystemProperty

protected java.lang.String forceSystemProperty

servletContextPath

protected java.lang.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.

servletContextURL

protected java.net.URL servletContextURL
This is the url to the servlet context directory

requestFactory

protected RequestFactory requestFactory
The requestFactory to use for incoming HTTP requests.
Constructor Detail

CocoonServlet

public CocoonServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig conf)
          throws javax.servlet.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.
Overrides:
init in class javax.servlet.GenericServlet
Parameters:
conf - The ServletConfig object from the servlet engine.
Throws:
javax.servlet.ServletException -  

destroy

public void destroy()
Dispose Cocoon when servlet is destroyed
Overrides:
destroy in class javax.servlet.GenericServlet

addClassLoaderURL

protected void addClassLoaderURL(java.net.URL URL)
Adds an URL to the classloader. Does nothing here, but is overriden in ParanoidCocoonServlet.

addClassLoaderDirectory

protected void addClassLoaderDirectory(java.lang.String dir)
Adds a directory to the classloader. Does nothing here, but is overriden in ParanoidCocoonServlet.

getClassPath

protected java.lang.String getClassPath()
                                 throws javax.servlet.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.
Throws:
javax.servlet.ServletException -  

getExtraClassPath

protected java.lang.String getExtraClassPath()
                                      throws javax.servlet.ServletException
Retreives the "extra-classpath" attribute, that needs to be added to the class path.
Throws:
javax.servlet.ServletException -  

service

public void service(javax.servlet.http.HttpServletRequest req,
                    javax.servlet.http.HttpServletResponse res)
             throws javax.servlet.ServletException,
                    java.io.IOException
Process the specified HttpServletRequest producing output on the specified HttpServletResponse.
Overrides:
service in class javax.servlet.http.HttpServlet

getEnvironment

protected Environment getEnvironment(java.lang.String uri,
                                     javax.servlet.http.HttpServletRequest req,
                                     javax.servlet.http.HttpServletResponse res)
                              throws java.lang.Exception
Create the environment for the request

updateEnvironment

protected void updateEnvironment()
                          throws javax.servlet.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).


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.