public abstract class ContainerBase extends LifecycleMBeanBase implements Container
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. |
|
Valve |
Valve added to this Container. |
removeChild |
Container |
Child container removed from this Container. |
|
Valve |
Valve removed from this Container. |
start |
null |
Container was started. |
stop |
null |
Container was stopped. |
Modifier and Type | Class and Description |
---|---|
protected class |
ContainerBase.ContainerBackgroundProcessor
Private thread class to invoke the backgroundProcess method
of this container and its children after a fixed delay.
|
protected class |
ContainerBase.PrivilegedAddChild
Perform addChild with the permissions of this class.
|
Lifecycle.SingleUse
Modifier and Type | Field and Description |
---|---|
protected AccessLog |
accessLog
The access log to use for requests normally handled by this container
that have been handled earlier in the processing chain.
|
protected int |
backgroundProcessorDelay
The processor delay for this component.
|
protected java.util.HashMap<java.lang.String,Container> |
children
The child Containers belonging to this Container, keyed by name.
|
protected Cluster |
cluster
The cluster with which this Container is associated.
|
protected java.util.List<ContainerListener> |
listeners
The container event listeners for this Container.
|
protected Log |
logger
The Logger implementation with which this Container is associated.
|
protected java.lang.String |
logName
Associated logger name.
|
protected java.lang.String |
name
The human-readable name of this Container.
|
protected Container |
parent
The parent Container to which this Container is a child.
|
protected java.lang.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 static StringManager |
sm
The string manager for this package.
|
protected boolean |
startChildren
Will children be started automatically when they are added.
|
protected java.util.concurrent.ThreadPoolExecutor |
startStopExecutor |
protected java.beans.PropertyChangeSupport |
support
The property change support for this component.
|
mserver
ADD_CHILD_EVENT, ADD_VALVE_EVENT, REMOVE_CHILD_EVENT, REMOVE_VALVE_EVENT
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
Constructor and Description |
---|
ContainerBase() |
Modifier and Type | Method and Description |
---|---|
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(java.beans.PropertyChangeListener listener)
Add a property change listener to this component.
|
void |
addValve(Valve valve)
Convenience method, intended for use by the digester to simplify the
process of adding Valves to containers.
|
void |
backgroundProcess()
Execute a periodic task, such as reloading, etc.
|
protected void |
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.
|
Container |
findChild(java.lang.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(java.lang.String type,
java.lang.Object data)
Notify all container event listeners that a particular event has
occurred for this Container.
|
AccessLog |
getAccessLog()
Obtain the AccessLog to use to log a request/response that is destined
for this container.
|
int |
getBackgroundProcessorDelay()
Get the delay between the invocation of the backgroundProcess method on
this container and its children.
|
java.io.File |
getCatalinaBase()
Obtain the location of CATALINA_BASE.
|
java.io.File |
getCatalinaHome()
Obtain the location of CATALINA_HOME.
|
javax.management.ObjectName[] |
getChildren() |
Cluster |
getCluster()
Return the Cluster with which this Container is associated.
|
protected Cluster |
getClusterInternal() |
protected java.lang.String |
getDomainInternal()
Method implemented by sub-classes to identify the domain in which MBeans
should be registered.
|
Log |
getLogger()
Return the Logger for this Container.
|
java.lang.String |
getLogName()
Return the logger name that the container will use.
|
java.lang.String |
getMBeanKeyProperties()
Calculate the key properties string to be added to an object's
ObjectName to indicate that it is associated with this container. |
java.lang.String |
getName()
Return a name string (suitable for use by humans) that describes this
Container.
|
Container |
getParent()
Return the Container for which this Container is a child, if there is
one.
|
java.lang.ClassLoader |
getParentClassLoader()
Return the parent class loader (if any) for this web application.
|
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.
|
protected Realm |
getRealmInternal() |
boolean |
getStartChildren()
Return if children of this container will be started automatically when
they are added to this container.
|
int |
getStartStopThreads()
Obtain the number of threads available for starting and stopping any
children associated with this container.
|
protected void |
initInternal()
Sub-classes wishing to perform additional initialization should override
this method, ensuring that super.initInternal() is the first call in the
overriding method.
|
void |
logAccess(Request request,
Response response,
long time,
boolean useDefault)
Check this container for an access log and if none is found, look to the
parent.
|
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(java.beans.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 |
setName(java.lang.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(java.lang.ClassLoader parent)
Set the parent class loader (if any) for this web application.
|
void |
setRealm(Realm realm)
Set the Realm with which this Container is associated.
|
void |
setStartChildren(boolean startChildren)
Set if children of this container will be started automatically when
they are added to this container.
|
void |
setStartStopThreads(int startStopThreads)
Sets the number of threads available for starting and stopping any
children associated with this container.
|
protected void |
startInternal()
Start this component and implement the requirements
of
LifecycleBase.startInternal() . |
protected void |
stopInternal()
Stop this component and implement the requirements
of
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.
|
getDomain, getObjectName, getObjectNameKeyProperties, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister
addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, init, removeLifecycleListener, setState, setState, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDomain, getObjectName
addLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stop
protected final java.util.HashMap<java.lang.String,Container> children
protected int backgroundProcessorDelay
protected final java.util.List<ContainerListener> listeners
protected Log logger
protected java.lang.String logName
protected Cluster cluster
protected java.lang.String name
protected Container parent
protected java.lang.ClassLoader parentClassLoader
protected final Pipeline pipeline
protected static final StringManager sm
protected boolean startChildren
protected final java.beans.PropertyChangeSupport support
protected volatile AccessLog accessLog
protected java.util.concurrent.ThreadPoolExecutor startStopExecutor
public int getStartStopThreads()
Container
getStartStopThreads
in interface Container
public void setStartStopThreads(int startStopThreads)
Container
setStartStopThreads
in interface Container
startStopThreads
- The new number of threads to be usedpublic int getBackgroundProcessorDelay()
getBackgroundProcessorDelay
in interface Container
public void setBackgroundProcessorDelay(int delay)
setBackgroundProcessorDelay
in interface Container
delay
- The delay in seconds between the invocation of
backgroundProcess methodspublic Log getLogger()
public java.lang.String getLogName()
Container
getLogName
in interface Container
public Cluster getCluster()
null
.getCluster
in interface Container
null
.protected Cluster getClusterInternal()
public void setCluster(Cluster cluster)
setCluster
in interface Container
cluster
- The newly associated Clusterpublic java.lang.String getName()
public void setName(java.lang.String name)
public boolean getStartChildren()
public void setStartChildren(boolean startChildren)
startChildren
- New value of the startChildren flagpublic Container getParent()
null
.public void setParent(Container container)
public java.lang.ClassLoader getParentClassLoader()
getParentClassLoader
in interface Container
Container.getParent()
.Container.getParentClassLoader()
. If no
parent has been set, return the system class loader.public void setParentClassLoader(java.lang.ClassLoader parent)
setParentClassLoader
in interface Container
parent
- The new parent class loaderpublic Pipeline getPipeline()
getPipeline
in interface Container
public Realm getRealm()
null
.protected Realm getRealmInternal()
public void setRealm(Realm realm)
public void addChild(Container child)
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 addedaddChild
in interface Container
child
- New child Container to be addedjava.lang.IllegalArgumentException
- if this exception is thrown by
the setParent()
method of the child Containerjava.lang.IllegalArgumentException
- if the new child does not have
a name unique from that of existing children of this Containerjava.lang.IllegalStateException
- if this Container does not support
child Containerspublic void addContainerListener(ContainerListener listener)
addContainerListener
in interface Container
listener
- The listener to addpublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener
in interface Container
listener
- The listener to addpublic Container findChild(java.lang.String name)
null
public Container[] findChildren()
findChildren
in interface Container
public ContainerListener[] findContainerListeners()
findContainerListeners
in interface Container
public void removeChild(Container child)
removeChild
in interface Container
child
- Existing child Container to be removedpublic void removeContainerListener(ContainerListener listener)
removeContainerListener
in interface Container
listener
- The listener to removepublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener
in interface Container
listener
- The listener to removeprotected void initInternal() throws LifecycleException
LifecycleMBeanBase
initInternal
in class LifecycleMBeanBase
LifecycleException
protected void startInternal() throws LifecycleException
LifecycleBase.startInternal()
.startInternal
in class LifecycleBase
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedprotected void stopInternal() throws LifecycleException
LifecycleBase.stopInternal()
.stopInternal
in class LifecycleBase
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedprotected void destroyInternal() throws LifecycleException
LifecycleMBeanBase
destroyInternal
in class LifecycleMBeanBase
LifecycleException
public void logAccess(Request request, Response response, long time, boolean useDefault)
logAccess
in interface Container
request
- Request (associated with the response) to logresponse
- Response (associated with the request) to logtime
- 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 logpublic AccessLog getAccessLog()
Container
getAccessLog
in interface Container
public void addValve(Valve valve)
Pipeline.addValve(Valve)
for full details. Components other than
the digester should use getPipeline()
.addValve(Valve)
in case a
future implementation provides an alternative method for the digester to
use.valve
- Valve to be addedjava.lang.IllegalArgumentException
- if this Container refused to
accept the specified Valvejava.lang.IllegalArgumentException
- if the specified Valve refuses to be
associated with this Containerjava.lang.IllegalStateException
- if the specified Valve is already
associated with a different Containerpublic void backgroundProcess()
backgroundProcess
in interface Container
public java.io.File getCatalinaBase()
Container
getCatalinaBase
in interface Container
public java.io.File getCatalinaHome()
Container
getCatalinaHome
in interface Container
public void fireContainerEvent(java.lang.String type, java.lang.Object data)
fireContainerEvent
in interface Container
type
- Event typedata
- Event dataprotected java.lang.String getDomainInternal()
LifecycleMBeanBase
getDomainInternal
in class LifecycleMBeanBase
public java.lang.String getMBeanKeyProperties()
Container
ObjectName
to indicate that it is associated with this container.getMBeanKeyProperties
in interface Container
public javax.management.ObjectName[] getChildren()
protected void threadStart()
protected void threadStop()
Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.