Class ChainServlet

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.apache.commons.chain.web.jakarta.ChainServlet
All Implemented Interfaces:
Servlet, ServletConfig, Serializable

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:
  • 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 Catalog will be created or updated. If not specified, it is expected that parsed resources will contain <catalog> elements (which will cause registration of the created Catalogs into the CatalogFactory for 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 RuleSet implementation to use for parsing configuration resources (this class must have a public zero-args constructor). If not defined, the standard RuleSet implementation will be used.

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):

  • 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 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: