Package org.apache.catalina
Interface Container
-
- All Known Implementing Classes:
AdHocWebModule,ContainerBase,ContextFacade,PEVirtualServer,PwcWebModule,StandardContext,StandardEngine,StandardHost,StandardWrapper,VirtualServer,WebModule
public interface ContainerA 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:
- Engine - Representation of the entire Catalina servlet engine, most likely containing one or more subcontainers that are either Host or Context implementations, or other custom groups.
- Host - Representation of a virtual host containing a number of Contexts.
- Context - Representation of a single ServletContext, which will typically contain one or more Wrappers for the supported servlets.
- Wrapper - Representation of an individual servlet definition (which may support multiple servlet instances if the servlet itself implements SingleThreadModel).
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:
- Loader - Class loader to use for integrating new Java classes for this Container into the JVM in which Catalina is running.
- Logger - Implementation of the
log()method signatures of theServletContextinterface. - Manager - Manager for the pool of Sessions associated with this Container.
- Realm - Read-only interface to a security domain, for authenticating user identities and their corresponding roles.
- Resources - JNDI directory context enabling access to static resources, enabling custom linkages to existing server components when Catalina is embedded in a larger server.
- Version:
- $Revision: 1.4 $ $Date: 2006/12/15 18:56:51 $
- Author:
- Craig R. McClanahan, Remy Maucherat
-
-
Field Summary
Fields Modifier and Type Field Description static StringADD_CHILD_EVENTThe ContainerEvent event type sent when a child container is added byaddChild().static StringADD_MAPPER_EVENTThe ContainerEvent event type sent when a Mapper is added byaddMapper().static StringADD_VALVE_EVENTThe ContainerEvent event type sent when a valve is added byaddValve(), if this Container supports pipelines.static StringREMOVE_CHILD_EVENTThe ContainerEvent event type sent when a child container is removed byremoveChild().static StringREMOVE_MAPPER_EVENTThe ContainerEvent event type sent when a Mapper is removed byremoveMapper().static StringREMOVE_VALVE_EVENTThe ContainerEvent event type sent when a valve is removed byremoveValve(), if this Container supports pipelines.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddChild(Container child)Add a new child Container to those associated with this Container, if supported.voidaddContainerListener(ContainerListener listener)Add a container event listener to this component.voidaddPropertyChangeListener(PropertyChangeListener listener)Add a property change listener to this component.voidbackgroundProcess()Execute a periodic task, such as reloading, etc.ContainerfindChild(String name)Return the child Container, associated with this Container, with the specified name (if any); otherwise, returnnullContainer[]findChildren()Return the set of children Containers associated with this Container.ContainerListener[]findContainerListeners()Return the set of container listeners associated with this Container.voidfireContainerEvent(String type, Object data)Notifies all event listeners of this Container of the given event.intgetBackgroundProcessorDelay()Get the delay between the invocation of the backgroundProcess method on this container and its children.StringgetInfo()Return descriptive information about this Container implementation and the corresponding version number, in the format<description>/<version>.LoadergetLoader()Return the Loader with which this Container is associated.LoggergetLogger()Return the Logger with which this Container is associated.ManagergetManager()Return the Manager with which this Container is associated.ObjectgetMappingObject()Return an object which may be utilized for mapping to this component.StringgetName()Return a name string (suitable for use by humans) that describes this Container.ContainergetParent()Return the Container for which this Container is a child, if there is one.ClassLoadergetParentClassLoader()Return the parent class loader (if any) for web applications.PipelinegetPipeline()Return the Pipeline object that manages the Valves associated with this Container.RealmgetRealm()Return the Realm with which this Container is associated.DirContextgetResources()Return the Resources with which this Container is associated.booleanhasCustomPipeline()voidinvoke(Request request, Response response)Process the specified Request, and generate the corresponding Response, according to the design of this particular Container.booleanisCheckIfRequestIsSecure()Indicates whether the request will be checked to see if it is secure before adding Pragma and Cache-control headers when proxy caching has been disabled.voidremoveChild(Container child)Remove an existing child Container from association with this parent Container.voidremoveContainerListener(ContainerListener listener)Remove a container event listener from this component.voidremovePropertyChangeListener(PropertyChangeListener listener)Remove a property change listener from this component.voidsetBackgroundProcessorDelay(int delay)Set the delay between the invocation of the execute method on this container and its children.voidsetCheckIfRequestIsSecure(boolean checkIfRequestIsSecure)Sets the checkIfRequestIsSecure property of this Container.voidsetLoader(Loader loader)Set the Loader with which this Container is associated.voidsetLogger(Logger logger)Set the Logger with which this Container is associated.voidsetManager(Manager manager)Set the Manager with which this Container is associated.voidsetName(String name)Set a name string (suitable for use by humans) that describes this Container.voidsetParent(Container container)Set the parent Container to which this Container is being added as a child.voidsetParentClassLoader(ClassLoader parent)Set the parent class loader (if any) for web applications.voidsetRealm(Realm realm)Set the Realm with which this Container is associated.voidsetResources(DirContext resources)Set the Resources object with which this Container is associated.
-
-
-
Field Detail
-
ADD_CHILD_EVENT
static final String ADD_CHILD_EVENT
The ContainerEvent event type sent when a child container is added byaddChild().- See Also:
- Constant Field Values
-
ADD_MAPPER_EVENT
static final String ADD_MAPPER_EVENT
The ContainerEvent event type sent when a Mapper is added byaddMapper().- See Also:
- Constant Field Values
-
ADD_VALVE_EVENT
static final String ADD_VALVE_EVENT
The ContainerEvent event type sent when a valve is added byaddValve(), 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 byremoveChild().- See Also:
- Constant Field Values
-
REMOVE_MAPPER_EVENT
static final String REMOVE_MAPPER_EVENT
The ContainerEvent event type sent when a Mapper is removed byremoveMapper().- See Also:
- Constant Field Values
-
REMOVE_VALVE_EVENT
static final String REMOVE_VALVE_EVENT
The ContainerEvent event type sent when a valve is removed byremoveValve(), 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, returnnull.
-
setLoader
void setLoader(Loader loader)
Set the Loader with which this Container is associated.- Parameters:
loader- The newly associated loader
-
getLogger
Logger 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 returnnull.
-
setLogger
void setLogger(Logger logger)
Set the Logger with which this Container is associated.- Parameters:
logger- The newly associated Logger
-
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 returnnull.
-
setManager
void setManager(Manager manager)
Set the Manager with which this Container is associated.- Parameters:
manager- The newly associated Manager
-
getMappingObject
Object getMappingObject()
Return an object which may be utilized for mapping to this component.
-
getPipeline
Pipeline getPipeline()
Return the Pipeline object that manages the Valves associated with this Container.
-
hasCustomPipeline
boolean hasCustomPipeline()
- Returns:
- true if this container was configured with a custom pipeline, false otherwise
-
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, returnnull.
-
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 (if any) for web applications.
-
setParentClassLoader
void setParentClassLoader(ClassLoader parent)
Set the parent class loader (if any) for web applications. 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 returnnull.
-
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 returnnull.
-
setResources
void setResources(DirContext resources) throws Exception
Set the Resources object with which this Container is associated.- Parameters:
resources- The newly associated Resources- Throws:
Exception
-
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'ssetParent()method must be called, with this Container as an argument. This method may thrown anIllegalArgumentExceptionif 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 thesetParent()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 Containers
-
addContainerListener
void addContainerListener(ContainerListener listener)
Add a container event listener to this component.- Parameters:
listener- The listener to add
-
fireContainerEvent
void fireContainerEvent(String type, Object data)
Notifies all event listeners of this Container of the given event.- Parameters:
type- Event typedata- Event data
-
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, returnnull- 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
void invoke(Request request, Response response) throws IOException, jakarta.servlet.ServletException
Process the specified Request, and generate the corresponding Response, according to the design of this particular Container.- Parameters:
request- Request to be processedresponse- Response to be produced- Throws:
IOException- if an input/output error occurred while processingjakarta.servlet.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
-
isCheckIfRequestIsSecure
boolean isCheckIfRequestIsSecure()
Indicates whether the request will be checked to see if it is secure before adding Pragma and Cache-control headers when proxy caching has been disabled.- Returns:
- true if the check is required; false otherwise.
-
setCheckIfRequestIsSecure
void setCheckIfRequestIsSecure(boolean checkIfRequestIsSecure)
Sets the checkIfRequestIsSecure property of this Container. Setting this property to true will check if the request is secure before adding Pragma and Cache-Control headers when proxy caching has been disabled.- Parameters:
checkIfRequestIsSecure- true if check is required, false otherwise
-
-