Save This Page
Home » apache-tomcat-6.0.26-src » org.apache » catalina » core » [javadoc | source]
org.apache.catalina.core
abstract public class: ContainerBase [javadoc | source]
java.lang.Object
   org.apache.catalina.core.ContainerBase

All Implemented Interfaces:
    Pipeline, Serializable, MBeanRegistration, Container, Lifecycle

Direct Known Subclasses:
    ExistingStandardWrapper, StandardEngine, StandardHost, StandardContext, ReplicatedContext, StandardWrapper

Abstract implementation of the Container interface, providing common functionality required by nearly every implementation. Classes extending this base class must implement getInfo(), and may implement a replacement for invoke().

All subclasses of this abstract base class will include support for a Pipeline object that defines the processing to be performed for each request received by the invoke() method of this class, utilizing the "Chain of Responsibility" design pattern. A subclass should encapsulate its own processing functionality as a Valve, and configure this Valve into the pipeline by calling setBasic().

This implementation fires property change events, per the JavaBeans design pattern, for changes in singleton properties. In addition, it fires the following ContainerEvent events to listeners who register themselves with addContainerListener():
Type Data Description
addChild Container Child container added to this Container.
addValve Valve Valve added to this Container.
removeChild Container Child container removed from this Container.
removeValve Valve Valve removed from this Container.
start null Container was started.
stop null Container was stopped.
Subclasses that fire additional events should document them in the class comments of the implementation class.

Nested Class Summary:
protected class  ContainerBase.PrivilegedAddChild  Perform addChild with the permissions of this class. addChild can be called with the XML parser on the stack, this allows the XML parser to have fewer privileges than Tomcat. 
protected class  ContainerBase.ContainerBackgroundProcessor  Private thread class to invoke the backgroundProcess method of this container and its children after a fixed delay. 
Field Summary
protected  HashMap children    The child Containers belonging to this Container, keyed by name. 
protected  int backgroundProcessorDelay    The processor delay for this component. 
protected  LifecycleSupport lifecycle    The lifecycle event support for this component. 
protected  ArrayList listeners    The container event listeners for this Container. 
protected  Loader loader    The Loader implementation with which this Container is associated. 
protected  Log logger    The Logger implementation with which this Container is associated. 
protected  String logName    Associated logger name. 
protected  Manager manager    The Manager implementation with which this Container is associated. 
protected  Cluster cluster    The cluster with which this Container is associated. 
protected  String name    The human-readable name of this Container. 
protected  Container parent    The parent Container to which this Container is a child. 
protected  ClassLoader parentClassLoader    The parent class loader to be configured when we install a Loader. 
protected  Pipeline pipeline    The Pipeline object with which this Container is associated. 
protected  Realm realm    The Realm with which this Container is associated. 
protected  DirContext resources    The resources DirContext object with which this Container is associated. 
protected static  StringManager sm    The string manager for this package. 
protected  boolean started    Has this component been started? 
protected  boolean initialized     
protected  boolean startChildren    Will children be started automatically when they are added. 
protected  PropertyChangeSupport support    The property change support for this component. 
protected  String type     
protected  String domain     
protected  String suffix     
protected  ObjectName oname     
protected  ObjectName controller     
protected transient  MBeanServer mserver     
Method from org.apache.catalina.core.ContainerBase Summary:
addChild,   addContainerListener,   addLifecycleListener,   addPropertyChangeListener,   addValve,   backgroundProcess,   createObjectName,   destroy,   findChild,   findChildren,   findContainerListeners,   findLifecycleListeners,   fireContainerEvent,   getBackgroundProcessorDelay,   getBasic,   getChildren,   getCluster,   getContainerSuffix,   getDomain,   getFirst,   getInfo,   getJSR77Suffix,   getJmxName,   getLoader,   getLogger,   getManager,   getMappingObject,   getName,   getObjectName,   getParent,   getParentClassLoader,   getParentName,   getPipeline,   getRealm,   getResources,   getStartChildren,   getType,   getValveObjectNames,   getValves,   init,   invoke,   logName,   postDeregister,   postRegister,   preDeregister,   preRegister,   removeChild,   removeContainerListener,   removeLifecycleListener,   removePropertyChangeListener,   removeValve,   setBackgroundProcessorDelay,   setBasic,   setCluster,   setDomain,   setLoader,   setManager,   setName,   setParent,   setParentClassLoader,   setRealm,   setResources,   setStartChildren,   start,   stop,   threadStart,   threadStop
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.catalina.core.ContainerBase Detail:
 public  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
 public  void addContainerListener(ContainerListener listener) 
    Add a container event listener to this component.
 public  void addLifecycleListener(LifecycleListener listener) 
    Add a lifecycle event listener to this component.
 public  void addPropertyChangeListener(PropertyChangeListener listener) 
    Add a property change listener to this component.
 public synchronized  void addValve(Valve valve) 
    Add a new Valve to the end of the pipeline associated with this Container. Prior to adding the Valve, the Valve's setContainer method must be called, with this Container as an argument. The method may throw an IllegalArgumentException if this Valve chooses not to be associated with this Container, or IllegalStateException if it is already associated with a different Container.
 public  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.
 public ObjectName createObjectName(String domain,
    ObjectName parent) throws Exception 
 public  void destroy() throws Exception 
 public Container findChild(String name) 
    Return the child Container, associated with this Container, with the specified name (if any); otherwise, return null
 public 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 LifecycleListener[] findLifecycleListeners() 
    Get the lifecycle listeners associated with this lifecycle. If this Lifecycle has no listeners registered, a zero-length array is returned.
 public  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.
 public 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.
 public Valve getBasic() 

    Return the Valve instance that has been distinguished as the basic Valve for this Pipeline (if any).

 public ObjectName[] getChildren() 
 public 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.
 public String getContainerSuffix() 
 public String getDomain() 
 public Valve getFirst() 
    Return the first valve in the pipeline.
 public String getInfo() 
    Return descriptive information about this Container implementation and the corresponding version number, in the format <description>/<version>.
 protected String getJSR77Suffix() 
 public ObjectName getJmxName() 
 public 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.
 public 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.
 public 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.
 public Object getMappingObject() 
    Return an object which may be utilized for mapping to this component.
 public 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.
 public String getObjectName() 
 public Container getParent() 
    Return the Container for which this Container is a child, if there is one. If there is no defined parent, return null.
 public ClassLoader getParentClassLoader() 
    Return the parent class loader (if any) for this web application. This call is meaningful only after a Loader has been configured.
 public ObjectName getParentName() throws MalformedObjectNameException 
 public Pipeline getPipeline() 
    Return the Pipeline object that manages the Valves associated with this Container.
 public 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.
 public DirContext getResources() 
    Return the resources DirContext object 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 boolean getStartChildren() 
    Return if children of this container will be started automatically when they are added to this container.
 public String getType() 
 public ObjectName[] getValveObjectNames() 
 public Valve[] getValves() 
    Return the set of Valves in the pipeline associated with this Container, including the basic Valve (if any). If there are no such Valves, a zero-length array is returned.
 public  void init() throws Exception 
    Init method, part of the MBean lifecycle. If the container was added via JMX, it'll register itself with the parent, using the ObjectName conventions to locate the parent. If the container was added directly and it doesn't have an ObjectName, it'll create a name and register itself with the JMX console. On destroy(), the object will unregister.
 public  void invoke(Request request,
    Response response) throws IOException, ServletException 
    Process the specified Request, to produce the corresponding Response, by invoking the first Valve in our pipeline (if any), or the basic Valve otherwise.
 protected String logName() 
    Return the abbreviated name of this container for logging messsages
 public  void postDeregister() 
 public  void postRegister(Boolean registrationDone) 
 public  void preDeregister() throws Exception 
 public ObjectName preRegister(MBeanServer server,
    ObjectName name) throws Exception 
 public  void removeChild(Container child) 
    Remove an existing child Container from association with this parent Container.
 public  void removeContainerListener(ContainerListener listener) 
    Remove a container event listener from this component.
 public  void removeLifecycleListener(LifecycleListener listener) 
    Remove a lifecycle event listener from this component.
 public  void removePropertyChangeListener(PropertyChangeListener listener) 
    Remove a property change listener from this component.
 public synchronized  void removeValve(Valve valve) 
    Remove the specified Valve from the pipeline associated with this Container, if it is found; otherwise, do nothing.
 public  void setBackgroundProcessorDelay(int delay) 
    Set the delay between the invocation of the execute method on this container and its children.
 public  void setBasic(Valve valve) 

    Set the Valve instance that has been distinguished as the basic Valve for this Pipeline (if any). Prioer to setting the basic Valve, the Valve's setContainer() will be called, if it implements Contained, with the owning Container as an argument. The method may throw an IllegalArgumentException if this Valve chooses not to be associated with this Container, or IllegalStateException if it is already associated with a different Container.

 public synchronized  void setCluster(Cluster cluster) 
    Set the Cluster with which this Container is associated.
 public  void setDomain(String domain) 
 public synchronized  void setLoader(Loader loader) 
    Set the Loader with which this Container is associated.
 public synchronized  void setManager(Manager manager) 
    Set the Manager with which this Container is associated.
 public  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.
 public  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.
 public  void setParentClassLoader(ClassLoader parent) 
    Set the parent class loader (if any) for this web application. 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.
 public synchronized  void setRealm(Realm realm) 
    Set the Realm with which this Container is associated.
 public synchronized  void setResources(DirContext resources) 
    Set the resources DirContext object with which this Container is associated.
 public  void setStartChildren(boolean startChildren) 
    Set if children of this container will be started automatically when they are added to this container.
 public synchronized  void start() throws LifecycleException 
    Prepare for active use of the public methods of this Component.
 public synchronized  void stop() throws LifecycleException 
    Gracefully shut down active use of the public methods of this Component.
 protected  void threadStart() 
    Start the background thread that will periodically check for session timeouts.
 protected  void threadStop() 
    Stop the background thread that is periodically checking for session timeouts.