Class ChainServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- org.apache.commons.chain.web.ChainServlet
-
- All Implemented Interfaces:
java.io.Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
- Direct Known Subclasses:
ChainProcessor
public class ChainServlet extends javax.servlet.http.HttpServletServletthat automatically scans chain configuration files in the current web application at startup time, and exposes the result in aCatalogunder a specified servlet context attribute. The following servlet init parameters are utilized:- org.apache.commons.chain.CONFIG_CLASS_RESOURCE -
comma-delimited list of chain configuration resources to be loaded
via
ClassLoader.getResource()calls. If not specified, no class loader resources will be loaded. - org.apache.commons.chain.CONFIG_WEB_RESOURCE - comma-delimited list of chain configuration webapp resources to be loaded. If not specified, no web application resources will be loaded.
- org.apache.commons.chain.CONFIG_ATTR -
Name of the servlet context attribute under which the
resulting
Catalogwill be created or updated. If not specified, it is expected that parsed resources will contain<catalog>elements (which will cause registration of the createdCatalogs into theCatalogFactoryfor this application, and no servet context attribute will be created. NOTE - This parameter is deprecated. - org.apache.commons.chain.RULE_SET -
Fully qualified class name of a Digester
RuleSetimplementation to use for parsing configuration resources (this class must have a public zero-args constructor). If not defined, the standardRuleSetimplementation will be used.
When a web application that has configured this servlet is started, it will acquire the
Catalogunder the specified servlet context attribute key, creating a new one if there is none already there. ThisCatalogwill then be populated by scanning configuration resources from the following sources (loaded in this order):- Resources loaded from specified resource paths from the
webapp's class loader (via
ClassLoader.getResource()). - Resources loaded from specified resource paths in the web application
archive (via
ServetContext.getResource()).
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 theCatalogFactoryfor 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
ChainListenerto initialize yourCatalog. Note thatChainListeneruses 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
Fields Modifier and Type Field Description static java.lang.StringCONFIG_ATTRThe name of the context init parameter containing the name of the servlet context attribute under which our resultingCatalogwill be stored.static java.lang.StringCONFIG_CLASS_RESOURCEThe name of the context init parameter containing a comma-delimited list of class loader resources to be scanned.static java.lang.StringCONFIG_WEB_RESOURCEThe name of the context init parameter containing a comma-delimited list of web applicaton resources to be scanned.static java.lang.StringRULE_SETThe name of the context init parameter containing the fully qualified class name of theRuleSetimplementation for configuring ourConfigParser.
-
Constructor Summary
Constructors Constructor Description ChainServlet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()Clean up after ourselves as this application shuts down.voidinit()Create (if necessary) and configure aCatalogfrom the servlet init parameters that have been specified.voidservice(javax.servlet.http.HttpServletRequest request, javax.servlet.http.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
-
-
-
-
Field Detail
-
CONFIG_ATTR
public static final java.lang.String CONFIG_ATTR
The name of the context init parameter containing the name of the servlet context attribute under which our resulting
Catalogwill be stored.- See Also:
- Constant Field Values
-
CONFIG_CLASS_RESOURCE
public static final java.lang.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 java.lang.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 java.lang.String RULE_SET
The name of the context init parameter containing the fully qualified class name of the
RuleSetimplementation for configuring ourConfigParser.- See Also:
- Constant Field Values
-
-
Method Detail
-
destroy
public void destroy()
Clean up after ourselves as this application shuts down.
- Specified by:
destroyin interfacejavax.servlet.Servlet- Overrides:
destroyin classjavax.servlet.GenericServlet
-
init
public void init() throws javax.servlet.ServletExceptionCreate (if necessary) and configure a
Catalogfrom the servlet init parameters that have been specified.- Overrides:
initin classjavax.servlet.GenericServlet- Throws:
javax.servlet.ServletException- if the servlet could not be initialized
-
service
public void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOExceptionDoes nothing; this servlet's only purpose is to initialize a Chain and store it in the servlet context.
- Overrides:
servicein classjavax.servlet.http.HttpServlet- Parameters:
request- the request issued by the clientresponse- the response to be returned to the cliengt- Throws:
javax.servlet.ServletException- (this exception is never thrown)java.io.IOException- (this exception is never thrown)
-
-