org.apache.commons.chain.web
Class ChainServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.apache.commons.chain.web.ChainServlet
All Implemented Interfaces:
Serializable, Servlet, ServletConfig
Direct Known Subclasses:
ChainProcessor

public class ChainServlet
extends HttpServlet

Servlet that automatically scans chain configuration files in the current web application at startup time, and exposes the result in a Catalog under a specified servlet context attribute. The following servlet init parameters are utilized:

When a web application that has configured this servlet is started, it will acquire the Catalog under the specified servlet context attribute key, creating a new one if there is none already there. This Catalog will then be populated by scanning configuration resources from the following sources (loaded in this order):

If no attribute key is specified, on the other hand, parsed configuration resources are expected to contain <catalog> elements, and the catalogs will be registered with the CatalogFactory for this web application.

This class runs on Servlet 2.2 or later. If you are running on a Servlet 2.3 or later system, you should also consider using ChainListener to initialize your Catalog. Note that ChainListener uses parameters of the same names, but they are context init parameters instead of servlet init parameters. Because of this, you can use both facilities in the same application, if desired.

Author:
Matthew J. Sgarlata, Craig R. McClanahan, Ted Husted
See Also:
Serialized Form

Field Summary
static String CONFIG_ATTR
          The name of the context init parameter containing the name of the servlet context attribute under which our resulting Catalog will be stored.
static String CONFIG_CLASS_RESOURCE
          The name of the context init parameter containing a comma-delimited list of class loader resources to be scanned.
static String CONFIG_WEB_RESOURCE
          The name of the context init parameter containing a comma-delimited list of web applicaton resources to be scanned.
static String RULE_SET
          The name of the context init parameter containing the fully qualified class name of the RuleSet implementation for configuring our ConfigParser.
 
Constructor Summary
ChainServlet()
           
 
Method Summary
 void destroy()
          Clean up after ourselves as this application shuts down.
 void init()
          Create (if necessary) and configure a Catalog from the servlet init parameters that have been specified.
 void service(HttpServletRequest request, HttpServletResponse response)
          Does nothing; this servlet's only purpose is to initialize a Chain and store it in the servlet context.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, 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

CONFIG_ATTR

public static final String CONFIG_ATTR

The name of the context init parameter containing the name of the servlet context attribute under which our resulting Catalog will be stored.

See Also:
Constant Field Values

CONFIG_CLASS_RESOURCE

public static final String CONFIG_CLASS_RESOURCE

The name of the context init parameter containing a comma-delimited list of class loader resources to be scanned.

See Also:
Constant Field Values

CONFIG_WEB_RESOURCE

public static final String CONFIG_WEB_RESOURCE

The name of the context init parameter containing a comma-delimited list of web applicaton resources to be scanned.

See Also:
Constant Field Values

RULE_SET

public static final String RULE_SET

The name of the context init parameter containing the fully qualified class name of the RuleSet implementation for configuring our ConfigParser.

See Also:
Constant Field Values
Constructor Detail

ChainServlet

public ChainServlet()
Method Detail

destroy

public void destroy()

Clean up after ourselves as this application shuts down.

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

init

public void init()
          throws ServletException

Create (if necessary) and configure a Catalog from the servlet init parameters that have been specified.

Overrides:
init in class GenericServlet
Throws:
ServletException - if the servlet could not be initialized

service

public void service(HttpServletRequest request,
                    HttpServletResponse response)
             throws ServletException,
                    IOException

Does nothing; this servlet's only purpose is to initialize a Chain and store it in the servlet context.

Overrides:
service in class HttpServlet
Parameters:
request - the request issued by the client
response - the response to be returned to the cliengt
Throws:
ServletException - (this exception is never thrown)
IOException - (this exception is never thrown)


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