FileDocCategorySizeDatePackage
Container.javaAPI DocApache Tomcat 6.0.1415378Fri Jul 20 04:20:30 BST 2007org.apache.catalina

Container

public interface Container
A Container is an object that can execute requests received from a client, and return responses based on those requests. A Container may optionally support a pipeline of Valves that process the request in an order configured at runtime, by implementing the Pipeline interface as well.

Containers will exist at several conceptual levels within Catalina. The following examples represent common cases:

  • Engine - Representation of the entire Catalina servlet engine, most likely containing one or more subcontainers that are either Host or Context implementations, or other custom groups.
  • Host - Representation of a virtual host containing a number of Contexts.
  • Context - Representation of a single ServletContext, which will typically contain one or more Wrappers for the supported servlets.
  • Wrapper - Representation of an individual servlet definition (which may support multiple servlet instances if the servlet itself implements SingleThreadModel).
A given deployment of Catalina need not include Containers at all of the levels described above. For example, an administration application embedded within a network device (such as a router) might only contain a single Context and a few Wrappers, or even a single Wrapper if the application is relatively small. Therefore, Container implementations need to be designed so that they will operate correctly in the absence of parent Containers in a given deployment.

A Container may also be associated with a number of support components that provide functionality which might be shared (by attaching it to a parent Container) or individually customized. The following support components are currently recognized:

  • Loader - Class loader to use for integrating new Java classes for this Container into the JVM in which Catalina is running.
  • Logger - Implementation of the log() method signatures of the ServletContext interface.
  • Manager - Manager for the pool of Sessions associated with this Container.
  • Realm - Read-only interface to a security domain, for authenticating user identities and their corresponding roles.
  • Resources - JNDI directory context enabling access to static resources, enabling custom linkages to existing server components when Catalina is embedded in a larger server.
author
Craig R. McClanahan
author
Remy Maucherat
version
$Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $

Fields Summary
public static final String
ADD_CHILD_EVENT
The ContainerEvent event type sent when a child container is added by addChild().
public static final String
ADD_MAPPER_EVENT
The ContainerEvent event type sent when a Mapper is added by addMapper().
public static final String
ADD_VALVE_EVENT
The ContainerEvent event type sent when a valve is added by addValve(), if this Container supports pipelines.
public static final String
REMOVE_CHILD_EVENT
The ContainerEvent event type sent when a child container is removed by removeChild().
public static final String
REMOVE_MAPPER_EVENT
The ContainerEvent event type sent when a Mapper is removed by removeMapper().
public static final String
REMOVE_VALVE_EVENT
The ContainerEvent event type sent when a valve is removed by removeValve(), if this Container supports pipelines.
Constructors Summary
Methods Summary
public voidaddChild(org.apache.catalina.Container child)
Add a new child Container to those associated with this Container, if supported. Prior to adding this Container to the set of children, the child's setParent() method must be called, with this Container as an argument. This method may thrown an IllegalArgumentException if this Container chooses not to be attached to the specified Container, in which case it is not added

param
child New child Container to be added
exception
IllegalArgumentException if this exception is thrown by the setParent() method of the child Container
exception
IllegalArgumentException if the new child does not have a name unique from that of existing children of this Container
exception
IllegalStateException if this Container does not support child Containers

public voidaddContainerListener(ContainerListener listener)
Add a container event listener to this component.

param
listener The listener to add

public voidaddPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a property change listener to this component.

param
listener The listener to add

public voidbackgroundProcess()
Execute a periodic task, such as reloading, etc. This method will be invoked inside the classloading context of this container. Unexpected throwables will be caught and logged.

public org.apache.catalina.ContainerfindChild(java.lang.String name)
Return the child Container, associated with this Container, with the specified name (if any); otherwise, return null

param
name Name of the child Container to be retrieved

public org.apache.catalina.Container[]findChildren()
Return the set of children Containers associated with this Container. If this Container has no children, a zero-length array is returned.

public ContainerListener[]findContainerListeners()
Return the set of container listeners associated with this Container. If this Container has no registered container listeners, a zero-length array is returned.

public intgetBackgroundProcessorDelay()
Get the delay between the invocation of the backgroundProcess method on this container and its children. Child containers will not be invoked if their delay value is not negative (which would mean they are using their own thread). Setting this to a positive value will cause a thread to be spawn. After waiting the specified amount of time, the thread will invoke the executePeriodic method on this container and all its children.

public ClustergetCluster()
Return the Cluster with which this Container is associated. If there is no associated Cluster, return the Cluster associated with our parent Container (if any); otherwise return null.

public java.lang.StringgetInfo()
Return descriptive information about this Container implementation and the corresponding version number, in the format <description>/<version>.

public LoadergetLoader()
Return the Loader with which this Container is associated. If there is no associated Loader, return the Loader associated with our parent Container (if any); otherwise, return null.

public org.apache.juli.logging.LoggetLogger()
Return the Logger with which this Container is associated. If there is no associated Logger, return the Logger associated with our parent Container (if any); otherwise return null.

public ManagergetManager()
Return the Manager with which this Container is associated. If there is no associated Manager, return the Manager associated with our parent Container (if any); otherwise return null.

public java.lang.ObjectgetMappingObject()
Return an object which may be utilized for mapping to this component.

public java.lang.StringgetName()
Return a name string (suitable for use by humans) that describes this Container. Within the set of child containers belonging to a particular parent, Container names must be unique.

public java.lang.StringgetObjectName()
Return the JMX name associated with this container.

public org.apache.catalina.ContainergetParent()
Return the Container for which this Container is a child, if there is one. If there is no defined parent, return null.

public java.lang.ClassLoadergetParentClassLoader()
Return the parent class loader (if any) for web applications.

public PipelinegetPipeline()
Return the Pipeline object that manages the Valves associated with this Container.

public RealmgetRealm()
Return the Realm with which this Container is associated. If there is no associated Realm, return the Realm associated with our parent Container (if any); otherwise return null.

public javax.naming.directory.DirContextgetResources()
Return the Resources with which this Container is associated. If there is no associated Resources object, return the Resources associated with our parent Container (if any); otherwise return null.

public voidinvoke(org.apache.catalina.connector.Request request, org.apache.catalina.connector.Response response)
Process the specified Request, and generate the corresponding Response, according to the design of this particular Container.

param
request Request to be processed
param
response Response to be produced
exception
IOException if an input/output error occurred while processing
exception
ServletException if a ServletException was thrown while processing this request

public voidremoveChild(org.apache.catalina.Container child)
Remove an existing child Container from association with this parent Container.

param
child Existing child Container to be removed

public voidremoveContainerListener(ContainerListener listener)
Remove a container event listener from this component.

param
listener The listener to remove

public voidremovePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a property change listener from this component.

param
listener The listener to remove

public voidsetBackgroundProcessorDelay(int delay)
Set the delay between the invocation of the execute method on this container and its children.

param
delay The delay in seconds between the invocation of backgroundProcess methods

public voidsetCluster(Cluster cluster)
Set the Cluster with which this Container is associated.

param
cluster the Cluster with which this Container is associated.

public voidsetLoader(Loader loader)
Set the Loader with which this Container is associated.

param
loader The newly associated loader

public voidsetManager(Manager manager)
Set the Manager with which this Container is associated.

param
manager The newly associated Manager

public voidsetName(java.lang.String name)
Set a name string (suitable for use by humans) that describes this Container. Within the set of child containers belonging to a particular parent, Container names must be unique.

param
name New name of this container
exception
IllegalStateException if this Container has already been added to the children of a parent Container (after which the name may not be changed)

public voidsetParent(org.apache.catalina.Container container)
Set the parent Container to which this Container is being added as a child. This Container may refuse to become attached to the specified Container by throwing an exception.

param
container Container to which this Container is being added as a child
exception
IllegalArgumentException if this Container refuses to become attached to the specified Container

public voidsetParentClassLoader(java.lang.ClassLoader parent)
Set the parent class loader (if any) for web applications. This call is meaningful only before a Loader has been configured, and the specified value (if non-null) should be passed as an argument to the class loader constructor.

param
parent The new parent class loader

public voidsetRealm(Realm realm)
Set the Realm with which this Container is associated.

param
realm The newly associated Realm

public voidsetResources(javax.naming.directory.DirContext resources)
Set the Resources object with which this Container is associated.

param
resources The newly associated Resources