Apache Tomcat 7.0.28

org.apache.catalina
Interface Container

All Superinterfaces:
Lifecycle
All Known Subinterfaces:
Context, Engine, Host, Wrapper
All Known Implementing Classes:
ContainerBase, FailedContext, ReplicatedContext, StandardContext, StandardEngine, StandardHost, StandardWrapper, Tomcat.ExistingStandardWrapper

public interface Container
extends Lifecycle

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:

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:

Version:
$Id: Container.java 1238006 2012-01-30 20:57:00Z markt $
Author:
Craig R. McClanahan, Remy Maucherat

Field Summary
static String ADD_CHILD_EVENT
          The ContainerEvent event type sent when a child container is added by addChild().
static String ADD_MAPPER_EVENT
          Deprecated. Unused. Will be removed in Tomcat 8.0.x.
static String ADD_VALVE_EVENT
          The ContainerEvent event type sent when a valve is added by addValve(), if this Container supports pipelines.
static String REMOVE_CHILD_EVENT
          The ContainerEvent event type sent when a child container is removed by removeChild().
static String REMOVE_MAPPER_EVENT
          Deprecated. Unused. Will be removed in Tomcat 8.0.x.
static String REMOVE_VALVE_EVENT
          The ContainerEvent event type sent when a valve is removed by removeValve(), if this Container supports pipelines.
 
Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
 
Method Summary
 void addChild(Container child)
          Add a new child Container to those associated with this Container, if supported.
 void addContainerListener(ContainerListener listener)
          Add a container event listener to this component.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add a property change listener to this component.
 void backgroundProcess()
          Execute a periodic task, such as reloading, etc.
 Container findChild(String name)
          Return the child Container, associated with this Container, with the specified name (if any); otherwise, return null
 Container[] findChildren()
          Return the set of children Containers associated with this Container.
 ContainerListener[] findContainerListeners()
          Return the set of container listeners associated with this Container.
 void fireContainerEvent(String type, Object data)
          Notify all container event listeners that a particular event has occurred for this Container.
 AccessLog getAccessLog()
          Identify the AccessLog to use to log a request/response that was destined for this container but was handled earlier in the processing chain so that the request/response still appears in the correct access logs.
 int getBackgroundProcessorDelay()
          Get the delay between the invocation of the backgroundProcess method on this container and its children.
 Cluster getCluster()
          Return the Cluster with which this Container is associated.
 String getInfo()
          Return descriptive information about this Container implementation and the corresponding version number, in the format <description>/<version>.
 Loader getLoader()
          Return the Loader with which this Container is associated.
 Log getLogger()
          Return the Logger with which this Container is associated.
 Manager getManager()
          Return the Manager with which this Container is associated.
 Object getMappingObject()
          Deprecated. 
 String getName()
          Return a name string (suitable for use by humans) that describes this Container.
 ObjectName getObjectName()
          Return the JMX name associated with this container.
 Container getParent()
          Return the Container for which this Container is a child, if there is one.
 ClassLoader getParentClassLoader()
          Return the parent class loader for this component.
 Pipeline getPipeline()
          Return the Pipeline object that manages the Valves associated with this Container.
 Realm getRealm()
          Return the Realm with which this Container is associated.
 DirContext getResources()
          Return the Resources with which this Container is associated.
 int getStartStopThreads()
          Returns the number of threads available for starting and stopping any children associated with this container.
 void invoke(Request request, Response response)
          Deprecated. Unused. Will be removed in Tomcat 8.0.x.
 void logAccess(Request request, Response response, long time, boolean useDefault)
          Log a request/response that was destined for this container but has been handled earlier in the processing chain so that the request/response still appears in the correct access logs.
 void removeChild(Container child)
          Remove an existing child Container from association with this parent Container.
 void removeContainerListener(ContainerListener listener)
          Remove a container event listener from this component.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Remove a property change listener from this component.
 void setBackgroundProcessorDelay(int delay)
          Set the delay between the invocation of the execute method on this container and its children.
 void setCluster(Cluster cluster)
          Set the Cluster with which this Container is associated.
 void setLoader(Loader loader)
          Set the Loader with which this Container is associated.
 void setManager(Manager manager)
          Set the Manager with which this Container is associated.
 void setName(String name)
          Set a name string (suitable for use by humans) that describes this Container.
 void setParent(Container container)
          Set the parent Container to which this Container is being added as a child.
 void setParentClassLoader(ClassLoader parent)
          Set the parent class loader for this component.
 void setRealm(Realm realm)
          Set the Realm with which this Container is associated.
 void setResources(DirContext resources)
          Set the Resources object with which this Container is associated.
 void setStartStopThreads(int startStopThreads)
          Sets the number of threads available for starting and stopping any children associated with this container.
 
Methods inherited from interface org.apache.catalina.Lifecycle
addLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stop
 

Field Detail

ADD_CHILD_EVENT

static final String ADD_CHILD_EVENT
The ContainerEvent event type sent when a child container is added by addChild().

See Also:
Constant Field Values

ADD_MAPPER_EVENT

@Deprecated
static final String ADD_MAPPER_EVENT
Deprecated. Unused. Will be removed in Tomcat 8.0.x.
The ContainerEvent event type sent when a Mapper is added by addMapper().

See Also:
Constant Field Values

ADD_VALVE_EVENT

static final String ADD_VALVE_EVENT
The ContainerEvent event type sent when a valve is added by addValve(), if this Container supports pipelines.

See Also:
Constant Field Values

REMOVE_CHILD_EVENT

static final String REMOVE_CHILD_EVENT
The ContainerEvent event type sent when a child container is removed by removeChild().

See Also:
Constant Field Values

REMOVE_MAPPER_EVENT

@Deprecated
static final String REMOVE_MAPPER_EVENT
Deprecated. Unused. Will be removed in Tomcat 8.0.x.
The ContainerEvent event type sent when a Mapper is removed by removeMapper().

See Also:
Constant Field Values

REMOVE_VALVE_EVENT

static final String REMOVE_VALVE_EVENT
The ContainerEvent event type sent when a valve is removed by removeValve(), if this Container supports pipelines.

See Also:
Constant Field Values
Method Detail

getInfo

String getInfo()
Return descriptive information about this Container implementation and the corresponding version number, in the format <description>/<version>.


getLoader

Loader getLoader()
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.


setLoader

void setLoader(Loader loader)
Set the Loader with which this Container is associated.

Parameters:
loader - The newly associated loader

getLogger

Log getLogger()
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.


getManager

Manager getManager()
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.


setManager

void setManager(Manager manager)
Set the Manager with which this Container is associated.

Parameters:
manager - The newly associated Manager

getMappingObject

@Deprecated
Object getMappingObject()
Deprecated. 

Return an object which may be utilized for mapping to this component.


getObjectName

ObjectName getObjectName()
Return the JMX name associated with this container.


getPipeline

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


getCluster

Cluster getCluster()
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.


setCluster

void setCluster(Cluster cluster)
Set the Cluster with which this Container is associated.

Parameters:
cluster - the Cluster with which this Container is associated.

getBackgroundProcessorDelay

int getBackgroundProcessorDelay()
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.


setBackgroundProcessorDelay

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

Parameters:
delay - The delay in seconds between the invocation of backgroundProcess methods

getName

String getName()
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.


setName

void setName(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.

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

getParent

Container getParent()
Return the Container for which this Container is a child, if there is one. If there is no defined parent, return null.


setParent

void setParent(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.

Parameters:
container - Container to which this Container is being added as a child
Throws:
IllegalArgumentException - if this Container refuses to become attached to the specified Container

getParentClassLoader

ClassLoader getParentClassLoader()
Return the parent class loader for this component. If not set, return getParent() getParentClassLoader(). If no parent has been set, return the system class loader.


setParentClassLoader

void setParentClassLoader(ClassLoader parent)
Set the parent class loader for this component. For Contexts 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.

Parameters:
parent - The new parent class loader

getRealm

Realm getRealm()
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.


setRealm

void setRealm(Realm realm)
Set the Realm with which this Container is associated.

Parameters:
realm - The newly associated Realm

getResources

DirContext getResources()
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.


setResources

void setResources(DirContext resources)
Set the Resources object with which this Container is associated.

Parameters:
resources - The newly associated Resources

backgroundProcess

void backgroundProcess()
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.


addChild

void addChild(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

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

addContainerListener

void addContainerListener(ContainerListener listener)
Add a container event listener to this component.

Parameters:
listener - The listener to add

addPropertyChangeListener

void addPropertyChangeListener(PropertyChangeListener listener)
Add a property change listener to this component.

Parameters:
listener - The listener to add

findChild

Container findChild(String name)
Return the child Container, associated with this Container, with the specified name (if any); otherwise, return null

Parameters:
name - Name of the child Container to be retrieved

findChildren

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


findContainerListeners

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.


invoke

@Deprecated
void invoke(Request request,
                       Response response)
            throws IOException,
                   ServletException
Deprecated. Unused. Will be removed in Tomcat 8.0.x.

Process the specified Request, and generate the corresponding Response, according to the design of this particular Container.

Parameters:
request - Request to be processed
response - Response to be produced
Throws:
IOException - if an input/output error occurred while processing
ServletException - if a ServletException was thrown while processing this request

removeChild

void removeChild(Container child)
Remove an existing child Container from association with this parent Container.

Parameters:
child - Existing child Container to be removed

removeContainerListener

void removeContainerListener(ContainerListener listener)
Remove a container event listener from this component.

Parameters:
listener - The listener to remove

removePropertyChangeListener

void removePropertyChangeListener(PropertyChangeListener listener)
Remove a property change listener from this component.

Parameters:
listener - The listener to remove

fireContainerEvent

void fireContainerEvent(String type,
                        Object data)
Notify all container event listeners that a particular event has occurred for this Container. The default implementation performs this notification synchronously using the calling thread.

Parameters:
type - Event type
data - Event data

logAccess

void logAccess(Request request,
               Response response,
               long time,
               boolean useDefault)
Log a request/response that was destined for this container but has been handled earlier in the processing chain so that the request/response still appears in the correct access logs.

Parameters:
request - Request (associated with the response) to log
response - Response (associated with the request) to log
time - Time taken to process the request/response in milliseconds (use 0 if not known)
useDefault - Flag that indicates that the request/response should be logged in the engine's default access log

getAccessLog

AccessLog getAccessLog()
Identify the AccessLog to use to log a request/response that was destined for this container but was handled earlier in the processing chain so that the request/response still appears in the correct access logs.


getStartStopThreads

int getStartStopThreads()
Returns the number of threads available for starting and stopping any children associated with this container. This allows start/stop calls to children to be processed in parallel.


setStartStopThreads

void setStartStopThreads(int startStopThreads)
Sets the number of threads available for starting and stopping any children associated with this container. This allows start/stop calls to children to be processed in parallel.

Parameters:
startStopThreads - The new number of threads to be used

Apache Tomcat 7.0.28

Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.