Top Description Inners Fields Constructors Methods
org.apache.catalina.core

public abstract Class ContainerBase

extends LifecycleMBeanBase
implements Container
Class Inheritance
All Implemented Interfaces
org.apache.catalina.Container, org.apache.catalina.Lifecycle
Known Direct Subclasses
org.apache.catalina.core.StandardContext, org.apache.catalina.core.StandardEngine, org.apache.catalina.core.StandardHost, org.apache.catalina.core.StandardWrapper
Imports
java.beans.PropertyChangeListener, .PropertyChangeSupport, java.io.File, java.security.AccessController, .PrivilegedAction, java.util.ArrayList, .HashMap, .List, java.util.concurrent.Callable, .CopyOnWriteArrayList, .ExecutionException, .ExecutorService, .Future, .ScheduledFuture, .TimeUnit, java.util.concurrent.locks.Lock, .ReadWriteLock, .ReentrantReadWriteLock, javax.management.ObjectName, org.apache.catalina.AccessLog, .Cluster, .Container, .ContainerEvent, .ContainerListener, .Context, .Engine, .Globals, .Host, .Lifecycle, .LifecycleException, .LifecycleState, .Loader, .Pipeline, .Realm, .Server, .Valve, .Wrapper, org.apache.catalina.connector.Request, .Response, org.apache.catalina.util.ContextName, .LifecycleMBeanBase, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.util.ExceptionUtils, .MultiThrowable, org.apache.tomcat.util.res.StringManager, org.apache.tomcat.util.threads.InlineExecutorService

Abstract implementation of the Container interface, providing common functionality required by nearly every implementation. Classes extending this base class must 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():

ContainerEvents fired by this implementation
Type Data Description
addChild Container Child container added to this Container.
pipeline.addValve Valve Valve added to this Container.
removeChild Container Child container removed from this Container.
pipeline.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.
Author
Craig R. McClanahan

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
ContainerBase.ContainerBackgroundProcessor

Private runnable class to invoke the backgroundProcess method of this container and its children after a fixed delay.

protected class
protected class
ContainerBase.PrivilegedAddChild

Perform addChild with the permissions of this class.

private static class
private static class

Field Summary

Modifier and TypeField and Description
protected volatile AccessLog
accessLog

The access log to use for requests normally handled by this container that have been handled earlier in the processing chain.

private volatile boolean
protected int
backgroundProcessorDelay

The processor delay for this component.

protected ScheduledFuture<?>
backgroundProcessorFuture

The future allowing control of the background processor.

protected final HashMap<String, Container>
children

The child Containers belonging to this Container, keyed by name.

protected Cluster
cluster

The cluster with which this Container is associated.

private final ReadWriteLock
protected final List<ContainerListener>
listeners

The container event listeners for this Container.

private static final Log
protected Log
logger

The Logger implementation with which this Container is associated.

protected String
logName

Associated logger name.

protected ScheduledFuture<?>
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 final Pipeline
pipeline

The Pipeline object with which this Container is associated.

private volatile Realm
realm

The Realm with which this Container is associated.

private final ReadWriteLock
realmLock

Lock used to control access to the Realm.

protected static final StringManager
sm

Hides org.apache.catalina.util.LifecycleMBeanBase.sm.

The string manager for this package.
protected boolean
startChildren

Will children be started automatically when they are added.

protected ExecutorService
private int
startStopThreads

The number of threads available to process start and stop events for any children associated with this container.

protected final PropertyChangeSupport
support

The property change support for this component.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addChild(Container
New child Container to be added
child
)

Implements org.apache.catalina.Container.addChild.

Add a new child Container to those associated with this Container, if supported.

private void
public void
addContainerListener(ContainerListener
The listener to add
listener
)

Implements org.apache.catalina.Container.addContainerListener.

Add a container event listener to this component.

public void
addPropertyChangeListener(PropertyChangeListener
The listener to add
listener
)

Implements org.apache.catalina.Container.addPropertyChangeListener.

Add a property change listener to this component.

public synchronized void
addValve(Valve
Valve to be added
valve
)

Convenience method, intended for use by the digester to simplify the process of adding Valves to containers.

public synchronized void
backgroundProcess()

Implements org.apache.catalina.Container.backgroundProcess.

Execute a periodic task, such as reloading, etc. This method will be invoked inside the classloading context of this container.

protected void
destroyInternal()

Overrides org.apache.catalina.util.LifecycleMBeanBase.destroyInternal.

Sub-classes wishing to perform additional clean-up should override this method, ensuring that super.destroyInternal() is the last call in the overriding method.

public Container
findChild(String
Name of the child Container to be retrieved
name
)

Implements org.apache.catalina.Container.findChild.

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

public Container[]
findChildren()

Implements org.apache.catalina.Container.findChildren.

Return the set of children Containers associated with this Container.

public ContainerListener[]
findContainerListeners()

Implements org.apache.catalina.Container.findContainerListeners.

Return the set of container listeners associated with this Container.

public void
fireContainerEvent(String
Event type
type
,
Object
Event data
data
)

Implements org.apache.catalina.Container.fireContainerEvent.

Notify all container event listeners that a particular event has occurred for this Container.

public AccessLog
getAccessLog()

Implements org.apache.catalina.Container.getAccessLog.

Obtain the AccessLog to use to log a request/response that is destined for this container.

public int
getBackgroundProcessorDelay()

Implements org.apache.catalina.Container.getBackgroundProcessorDelay.

Get the delay between the invocation of the backgroundProcess method on this container and its children.

public File
getCatalinaBase()

Implements org.apache.catalina.Container.getCatalinaBase.

Obtain the location of CATALINA_BASE.

public File
getCatalinaHome()

Implements org.apache.catalina.Container.getCatalinaHome.

Obtain the location of CATALINA_HOME.

public ObjectName[]
public Cluster
getCluster()

Implements org.apache.catalina.Container.getCluster.

Return the Cluster with which this Container is associated.

protected Cluster
protected String
getDomainInternal()

Implements abstract org.apache.catalina.util.LifecycleMBeanBase.getDomainInternal.

Method implemented by sub-classes to identify the domain in which MBeans should be registered.

public Log
getLogger()

Implements org.apache.catalina.Container.getLogger.

Return the Logger for this Container.

public String

Returns:

the abbreviated name of this container for logging messages
getLogName
()

Implements org.apache.catalina.Container.getLogName.

Return the logger name that the container will use.

public String
getMBeanKeyProperties()

Implements org.apache.catalina.Container.getMBeanKeyProperties.

Calculate the key properties string to be added to an object's ObjectName to indicate that it is associated with this container.

public String
getName()

Implements org.apache.catalina.Container.getName.

Return a name string (suitable for use by humans) that describes this Container.

public Container
getParent()

Implements org.apache.catalina.Container.getParent.

Return the Container for which this Container is a child, if there is one.

public ClassLoader
getParentClassLoader()

Implements org.apache.catalina.Container.getParentClassLoader.

Return the parent class loader (if any) for this web application.

public Pipeline
getPipeline()

Implements org.apache.catalina.Container.getPipeline.

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

public Realm
getRealm()

Implements org.apache.catalina.Container.getRealm.

Return the Realm with which this Container is associated.

protected Realm
public boolean

Returns:

true if the children will be started
getStartChildren
()

Return if children of this container will be started automatically when they are added to this container.

public int
getStartStopThreads()

Implements org.apache.catalina.Container.getStartStopThreads.

Obtain the number of threads available for starting and stopping any children associated with this container.

public void
logAccess(Request
Request (associated with the response) to log
request
,
Response
Response (associated with the request) to log
response
,
long
Time taken to process the request/response in milliseconds (use 0 if not known)
time
,
boolean
Flag that indicates that the request/response should be logged in the engine's default access log
useDefault
)

Implements org.apache.catalina.Container.logAccess.

Check this container for an access log and if none is found, look to the parent.

private void
public void
removeChild(Container
Existing child Container to be removed
child
)

Implements org.apache.catalina.Container.removeChild.

Remove an existing child Container from association with this parent Container.

public void
removeContainerListener(ContainerListener
The listener to remove
listener
)

Implements org.apache.catalina.Container.removeContainerListener.

Remove a container event listener from this component.

public void
removePropertyChangeListener(PropertyChangeListener
The listener to remove
listener
)

Implements org.apache.catalina.Container.removePropertyChangeListener.

Remove a property change listener from this component.

public void
setBackgroundProcessorDelay(int
The delay in seconds between the invocation of backgroundProcess methods
delay
)

Implements org.apache.catalina.Container.setBackgroundProcessorDelay.

Set the delay between the invocation of the execute method on this container and its children.

public void
setCluster(Cluster
The newly associated Cluster
cluster
)

Implements org.apache.catalina.Container.setCluster.

Set the Cluster with which this Container is associated.

public void
setName(String
New name of this container
name
)

Implements org.apache.catalina.Container.setName.

Set a name string (suitable for use by humans) that describes this Container.

public void
setParent(Container
Container to which this Container is being added as a child
container
)

Implements org.apache.catalina.Container.setParent.

Set the parent Container to which this Container is being added as a child.

public void
setParentClassLoader(ClassLoader
The new parent class loader
parent
)

Implements org.apache.catalina.Container.setParentClassLoader.

Set the parent class loader (if any) for this web application.

public void
setRealm(Realm
The newly associated Realm
realm
)

Implements org.apache.catalina.Container.setRealm.

Set the Realm with which this Container is associated.

public void
setStartChildren(boolean
New value of the startChildren flag
startChildren
)

Set if children of this container will be started automatically when they are added to this container.

public void
setStartStopThreads(int
The new number of threads to be used
startStopThreads
)

Implements org.apache.catalina.Container.setStartStopThreads.

Sets the number of threads available for starting and stopping any children associated with this container.

protected void
startInternal()

Implements abstract org.apache.catalina.util.LifecycleBase.startInternal.

Start this component and implement the requirements of org.apache.catalina.util.LifecycleBase#startInternal().

protected void
stopInternal()

Implements abstract org.apache.catalina.util.LifecycleBase.stopInternal.

Stop this component and implement the requirements of org.apache.catalina.util.LifecycleBase#stopInternal().

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.

public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.apache.catalina.util.LifecycleMBeanBase:
getDomaingetObjectNamegetObjectNameKeyPropertiesinitInternalpostDeregisterpostRegisterpreDeregisterpreRegisterregistersetDomainunregisterunregister