public interface Container extends Lifecycle
Containers will exist at several conceptual levels within Catalina. The following examples represent common cases:
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:
log()
method
signatures of the ServletContext
interface.
Lifecycle.SingleUse
Modifier and Type | Field and Description |
---|---|
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. |
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
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(PropertyChangeListener listener)
Add a property change listener to this component.
|
void |
backgroundProcess()
Execute a periodic task, such as reloading, etc.
|
Container |
findChild(String name)
Obtain a child Container by name.
|
Container[] |
findChildren()
Obtain the child Containers associated with this Container.
|
ContainerListener[] |
findContainerListeners()
Obtain the 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()
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.
|
Cluster |
getCluster()
Get the Cluster for this container.
|
String |
getInfo() |
Loader |
getLoader() |
Log |
getLogger()
Obtain the log to which events for this container should be logged.
|
Manager |
getManager() |
Object |
getMappingObject()
Deprecated.
|
String |
getName()
Return a name string (suitable for use by humans) that describes this
Container.
|
ObjectName |
getObjectName()
Obtain the JMX name for this container.
|
Container |
getParent()
Get the parent container.
|
ClassLoader |
getParentClassLoader()
Get the parent class loader.
|
Pipeline |
getPipeline()
Return the Pipeline object that manages the Valves associated with
this Container.
|
Realm |
getRealm()
Obtain the Realm with which this Container is associated.
|
DirContext |
getResources() |
int |
getStartStopThreads()
Obtain 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.
|
addLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stop
static final String ADD_CHILD_EVENT
addChild()
.@Deprecated static final String ADD_MAPPER_EVENT
addMapper()
.static final String ADD_VALVE_EVENT
addValve()
, if this Container supports pipelines.static final String REMOVE_CHILD_EVENT
removeChild()
.@Deprecated static final String REMOVE_MAPPER_EVENT
removeMapper()
.static final String REMOVE_VALVE_EVENT
removeValve()
, if this Container supports pipelines.String getInfo()
<description>/<version>
.Loader getLoader()
null
.void setLoader(Loader loader)
loader
- The newly associated loaderLog getLogger()
null
.Manager getManager()
null
.void setManager(Manager manager)
manager
- The newly associated Manager@Deprecated Object getMappingObject()
ObjectName getObjectName()
Pipeline getPipeline()
Cluster getCluster()
null
.void setCluster(Cluster cluster)
cluster
- the Cluster with which this Container is associated.int getBackgroundProcessorDelay()
backgroundProcess()
method on this container and all
children with non-positive delay values.void setBackgroundProcessorDelay(int delay)
delay
- The delay in seconds between the invocation of
backgroundProcess methodsString getName()
void setName(String name)
name
- New name of this containerIllegalStateException
- if this Container has already been
added to the children of a parent Container (after which the name
may not be changed)Container getParent()
null
.void setParent(Container container)
container
- Container to which this Container is being added
as a childIllegalArgumentException
- if this Container refuses to become
attached to the specified ContainerClassLoader getParentClassLoader()
getParent()
.getParentClassLoader()
. If no
parent has been set, return the system class loader.void setParentClassLoader(ClassLoader parent)
Context
s
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.parent
- The new parent class loaderRealm getRealm()
null
.void setRealm(Realm realm)
realm
- The newly associated RealmDirContext getResources()
null
.void setResources(DirContext resources)
resources
- The newly associated Resourcesvoid backgroundProcess()
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 addedchild
- New child Container to be addedIllegalArgumentException
- if this exception is thrown by
the setParent()
method of the child ContainerIllegalArgumentException
- if the new child does not have
a name unique from that of existing children of this ContainerIllegalStateException
- if this Container does not support
child Containersvoid addContainerListener(ContainerListener listener)
listener
- The listener to addvoid addPropertyChangeListener(PropertyChangeListener listener)
listener
- The listener to addContainer findChild(String name)
name
- Name of the child Container to be retrievednull
if
no such child exists.Container[] findChildren()
ContainerListener[] findContainerListeners()
@Deprecated void invoke(Request request, Response response) throws IOException, ServletException
request
- Request to be processedresponse
- Response to be producedIOException
- if an input/output error occurred while
processingServletException
- if a ServletException was thrown
while processing this requestvoid removeChild(Container child)
child
- Existing child Container to be removedvoid removeContainerListener(ContainerListener listener)
listener
- The listener to removevoid removePropertyChangeListener(PropertyChangeListener listener)
listener
- The listener to removevoid fireContainerEvent(String type, Object data)
type
- Event typedata
- Event datavoid logAccess(Request request, Response response, long time, boolean useDefault)
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 logAccessLog getAccessLog()
int getStartStopThreads()
void setStartStopThreads(int startStopThreads)
startStopThreads
- The new number of threads to be usedCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.