org.apache.catalina.core

Class StandardWrapper

Implemented Interfaces:
ServletConfig, Container, Lifecycle, MBeanRegistration, Pipeline, Serializable, Wrapper

public class StandardWrapper
extends ContainerBase
implements ServletConfig, Wrapper

Standard implementation of the Wrapper interface that represents an individual servlet definition. No child Containers are allowed, and the parent Container must be a Context.

Version:
$Revision: 1.43.2.3 $ $Date: 2004/11/18 22:13:36 $

Authors:
Craig R. McClanahan
Remy Maucherat

Nested Class Summary

Nested classes/interfaces inherited from class org.apache.catalina.core.ContainerBase

ContainerBase.ContainerBackgroundProcessor, ContainerBase.PrivilegedAddChild

Field Summary

Fields inherited from class org.apache.catalina.core.ContainerBase

backgroundProcessorDelay, children, cluster, controller, debug, domain, initialized, lifecycle, listeners, loader, logger, manager, mserver, name, oname, parent, parentClassLoader, pipeline, realm, resources, sm, started, suffix, support, type

Fields inherited from interface org.apache.catalina.Container

ADD_CHILD_EVENT, ADD_MAPPER_EVENT, ADD_VALVE_EVENT, REMOVE_CHILD_EVENT, REMOVE_MAPPER_EVENT, REMOVE_VALVE_EVENT

Fields inherited from interface org.apache.catalina.Lifecycle

AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, START_EVENT, STOP_EVENT

Constructor Summary

StandardWrapper()
Create a new StandardWrapper component with the default basic Valve.

Method Summary

void
addChild(Container child)
Refuse to add a child Container, because Wrappers are the lowest level of the Container hierarchy.
protected void
addDefaultMapper(String mapperClass)
Add a default Mapper implementation if none have been configured explicitly.
void
addInitParameter(String name, String value)
Add a new servlet initialization parameter for this servlet.
void
addInstanceListener(InstanceListener listener)
Add a new listener interested in InstanceEvents.
void
addMapping(String mapping)
Add a mapping associated with the Wrapper.
void
addSecurityReference(String name, String link)
Add a new security role reference record to the set of records for this servlet.
Servlet
allocate()
Allocate an initialized instance of this Servlet that is ready to have its service() method called.
void
deallocate(Servlet servlet)
Return this previously allocated servlet to the pool of available instances.
String
findInitParameter(String name)
Return the value for the specified initialization parameter name, if any; otherwise return null.
String[]
findInitParameters()
Return the names of all defined initialization parameters for this servlet.
Wrapper
findMappingObject()
FIXME: Fooling introspection ...
String[]
findMappings()
Return the mappings associated with this wrapper.
String
findSecurityReference(String name)
Return the security role link for the specified security role reference name, if any; otherwise return null.
String[]
findSecurityReferences()
Return the set of security role reference names associated with this servlet, if any; otherwise return a zero-length array.
long
getAvailable()
Return the available date/time for this servlet, in milliseconds since the epoch.
int
getClassLoadTime()
int
getCountAllocated()
Return the number of active allocations of this servlet, even if they are all for the same instance (as will be true for servlets that do not implement SingleThreadModel.
int
getDebug()
Return the debugging detail level for this component.
String
getEngineName()
int
getErrorCount()
String
getInfo()
Return descriptive information about this Container implementation and the corresponding version number, in the format <description>/<version>.
String
getInitParameter(String name)
Return the initialization parameter value for the specified name, if any; otherwise return null.
Enumeration
getInitParameterNames()
Return the set of initialization parameter names defined for this servlet.
InstanceSupport
getInstanceSupport()
Return the InstanceSupport object for this Wrapper instance.
String
getJspFile()
Return the context-relative URI of the JSP file for this servlet.
int
getLoadOnStartup()
Return the load-on-startup order value (negative value means load on first call).
String
getLoadOnStartupString()
long
getLoadTime()
int
getMaxInstances()
Return maximum number of instances that will be allocated when a single thread model servlet is used.
long
getMaxTime()
long
getMinTime()
long
getProcessingTime()
int
getRequestCount()
String
getRunAs()
Return the run-as identity for this servlet.
String
getServletClass()
Return the fully qualified servlet class name for this servlet.
ServletContext
getServletContext()
Return the servlet context with which this servlet is associated.
String
getServletName()
Return the name of this servlet.
void
incrementErrorCount()
Increment the error count used for monitoring.
boolean
isEventProvider()
boolean
isSingleThreadModel()
Return true if the servlet class represented by this component implements the SingleThreadModel interface.
boolean
isStateManageable()
boolean
isStatisticsProvider()
boolean
isUnavailable()
Is this servlet currently unavailable?
void
load()
Load and initialize an instance of this servlet, if there is not already at least one initialized instance.
Servlet
loadServlet()
Load and initialize an instance of this servlet, if there is not already at least one initialized instance.
protected String
logName()
Log the abbreviated name of this Container for logging messages.
protected void
registerJMX(StandardContext ctx)
void
removeInitParameter(String name)
Remove the specified initialization parameter from this servlet.
void
removeInstanceListener(InstanceListener listener)
Remove a listener no longer interested in InstanceEvents.
void
removeMapping(String mapping)
Remove a mapping associated with the wrapper.
void
removeSecurityReference(String name)
Remove any security role reference for the specified role name.
void
setAvailable(long available)
Set the available date/time for this servlet, in milliseconds since the epoch.
void
setDebug(int debug)
Set the debugging detail level for this component.
void
setErrorCount(int errorCount)
void
setJspFile(String jspFile)
Set the context-relative URI of the JSP file for this servlet.
void
setLoadOnStartup(int value)
Set the load-on-startup order value (negative value means load on first call).
void
setLoadOnStartupString(String value)
Set the load-on-startup order value from a (possibly null) string.
void
setLoadTime(long loadTime)
void
setMaxInstances(int maxInstances)
Set the maximum number of instances that will be allocated when a single thread model servlet is used.
void
setMaxTime(long maxTime)
void
setMinTime(long minTime)
void
setParent(Container container)
Set the parent Container of this Wrapper, but only if it is a Context.
void
setProcessingTime(long processingTime)
void
setRequestCount(int requestCount)
void
setRunAs(String runAs)
Set the run-as identity for this servlet.
void
setServletClass(String servletClass)
Set the fully qualified servlet class name for this servlet.
void
setServletName(String name)
Set the name of this servlet.
void
start()
Start this component, pre-loading the servlet if the load-on-startup value is set appropriately.
void
stop()
Stop this component, gracefully shutting down the servlet if it has been initialized.
String
toString()
Return a String representation of this component.
void
unavailable(UnavailableException unavailable)
Process an UnavailableException, marking this servlet as unavailable for the specified amount of time.
void
unload()
Unload all initialized instances of this servlet, after calling the destroy() method for each instance.

Methods inherited from class org.apache.catalina.core.ContainerBase

addChild, addContainerListener, addLifecycleListener, addPropertyChangeListener, addValve, backgroundProcess, createObjectName, destroy, findChild, findChildren, findContainerListeners, findLifecycleListeners, fireContainerEvent, getBackgroundProcessorDelay, getBasic, getChildren, getCluster, getContainerSuffix, getDebug, getDomain, getInfo, getJSR77Suffix, getJmxName, getLoader, getLogger, getManager, getMappingObject, getName, getObjectName, getParent, getParentClassLoader, getParentName, getPipeline, getRealm, getResources, getType, getValveObjectNames, getValves, init, invoke, log, log, logName, postDeregister, postRegister, preDeregister, preRegister, removeChild, removeContainerListener, removeLifecycleListener, removePropertyChangeListener, removeValve, setBackgroundProcessorDelay, setBasic, setCluster, setDebug, setDomain, setLoader, setLogger, setManager, setName, setParent, setParentClassLoader, setRealm, setResources, start, stop, threadStart, threadStop

Constructor Details

StandardWrapper

public StandardWrapper()
Create a new StandardWrapper component with the default basic Valve.

Method Details

addChild

public void addChild(Container child)
Refuse to add a child Container, because Wrappers are the lowest level of the Container hierarchy.
Specified by:
addChild in interface Container
Overrides:
addChild in interface ContainerBase

Parameters:
child - Child container to be added


addDefaultMapper

protected void addDefaultMapper(String mapperClass)
Add a default Mapper implementation if none have been configured explicitly.

Parameters:
mapperClass - Java class name of the default Mapper


addInitParameter

public void addInitParameter(String name,
                             String value)
Add a new servlet initialization parameter for this servlet.
Specified by:
addInitParameter in interface Wrapper

Parameters:
name - Name of this initialization parameter to add
value - Value of this initialization parameter to add


addInstanceListener

public void addInstanceListener(InstanceListener listener)
Add a new listener interested in InstanceEvents.
Specified by:
addInstanceListener in interface Wrapper

Parameters:
listener - The new listener


addMapping

public void addMapping(String mapping)
Add a mapping associated with the Wrapper.
Specified by:
addMapping in interface Wrapper

Parameters:
mapping - The new wrapper mapping


addSecurityReference

public void addSecurityReference(String name,
                                 String link)
Add a new security role reference record to the set of records for this servlet.
Specified by:
addSecurityReference in interface Wrapper

Parameters:
name - Role name used within this servlet
link - Role name used within the web application


allocate

public Servlet allocate()
            throws ServletException
Allocate an initialized instance of this Servlet that is ready to have its service() method called. If the servlet class does not implement SingleThreadModel, the (only) initialized instance may be returned immediately. If the servlet class implements SingleThreadModel, the Wrapper implementation must ensure that this instance is not allocated again until it is deallocated by a call to deallocate().
Specified by:
allocate in interface Wrapper


deallocate

public void deallocate(Servlet servlet)
            throws ServletException
Return this previously allocated servlet to the pool of available instances. If this servlet class does not implement SingleThreadModel, no action is actually required.
Specified by:
deallocate in interface Wrapper

Parameters:
servlet - The servlet to be returned


findInitParameter

public String findInitParameter(String name)
Return the value for the specified initialization parameter name, if any; otherwise return null.
Specified by:
findInitParameter in interface Wrapper

Parameters:
name - Name of the requested initialization parameter


findInitParameters

public String[] findInitParameters()
Return the names of all defined initialization parameters for this servlet.
Specified by:
findInitParameters in interface Wrapper


findMappingObject

public Wrapper findMappingObject()
FIXME: Fooling introspection ...


findMappings

public String[] findMappings()
Return the mappings associated with this wrapper.
Specified by:
findMappings in interface Wrapper


findSecurityReference

public String findSecurityReference(String name)
Return the security role link for the specified security role reference name, if any; otherwise return null.
Specified by:
findSecurityReference in interface Wrapper

Parameters:
name - Security role reference used within this servlet


findSecurityReferences

public String[] findSecurityReferences()
Return the set of security role reference names associated with this servlet, if any; otherwise return a zero-length array.
Specified by:
findSecurityReferences in interface Wrapper


getAvailable

public long getAvailable()
Return the available date/time for this servlet, in milliseconds since the epoch. If this date/time is Long.MAX_VALUE, it is considered to mean that unavailability is permanent and any request for this servlet will return an SC_NOT_FOUND error. If this date/time is in the future, any request for this servlet will return an SC_SERVICE_UNAVAILABLE error. If it is zero, the servlet is currently available.
Specified by:
getAvailable in interface Wrapper


getClassLoadTime

public int getClassLoadTime()


getCountAllocated

public int getCountAllocated()
Return the number of active allocations of this servlet, even if they are all for the same instance (as will be true for servlets that do not implement SingleThreadModel.


getDebug

public int getDebug()
Return the debugging detail level for this component.
Overrides:
getDebug in interface ContainerBase


getEngineName

public String getEngineName()


getErrorCount

public int getErrorCount()


getInfo

public String getInfo()
Return descriptive information about this Container implementation and the corresponding version number, in the format <description>/<version>.
Specified by:
getInfo in interface Container
Overrides:
getInfo in interface ContainerBase


getInitParameter

public String getInitParameter(String name)
Return the initialization parameter value for the specified name, if any; otherwise return null.

Parameters:
name - Name of the initialization parameter to retrieve


getInitParameterNames

public Enumeration getInitParameterNames()
Return the set of initialization parameter names defined for this servlet. If none are defined, an empty Enumeration is returned.


getInstanceSupport

public InstanceSupport getInstanceSupport()
Return the InstanceSupport object for this Wrapper instance.


getJspFile

public String getJspFile()
Return the context-relative URI of the JSP file for this servlet.
Specified by:
getJspFile in interface Wrapper


getLoadOnStartup

public int getLoadOnStartup()
Return the load-on-startup order value (negative value means load on first call).
Specified by:
getLoadOnStartup in interface Wrapper


getLoadOnStartupString

public String getLoadOnStartupString()


getLoadTime

public long getLoadTime()


getMaxInstances

public int getMaxInstances()
Return maximum number of instances that will be allocated when a single thread model servlet is used.


getMaxTime

public long getMaxTime()


getMinTime

public long getMinTime()


getProcessingTime

public long getProcessingTime()


getRequestCount

public int getRequestCount()


getRunAs

public String getRunAs()
Return the run-as identity for this servlet.
Specified by:
getRunAs in interface Wrapper


getServletClass

public String getServletClass()
Return the fully qualified servlet class name for this servlet.
Specified by:
getServletClass in interface Wrapper


getServletContext

public ServletContext getServletContext()
Return the servlet context with which this servlet is associated.


getServletName

public String getServletName()
Return the name of this servlet.


incrementErrorCount

public void incrementErrorCount()
Increment the error count used for monitoring.
Specified by:
incrementErrorCount in interface Wrapper


isEventProvider

public boolean isEventProvider()


isSingleThreadModel

public boolean isSingleThreadModel()
Return true if the servlet class represented by this component implements the SingleThreadModel interface.


isStateManageable

public boolean isStateManageable()


isStatisticsProvider

public boolean isStatisticsProvider()


isUnavailable

public boolean isUnavailable()
Is this servlet currently unavailable?
Specified by:
isUnavailable in interface Wrapper


load

public void load()
            throws ServletException
Load and initialize an instance of this servlet, if there is not already at least one initialized instance. This can be used, for example, to load servlets that are marked in the deployment descriptor to be loaded at server startup time.

IMPLEMENTATION NOTE: Servlets whose classnames begin with org.apache.catalina. (so-called "container" servlets) are loaded by the same classloader that loaded this class, rather than the classloader for the current web application. This gives such classes access to Catalina internals, which are prevented for classes loaded for web applications.

Specified by:
load in interface Wrapper


loadServlet

public Servlet loadServlet()
            throws ServletException
Load and initialize an instance of this servlet, if there is not already at least one initialized instance. This can be used, for example, to load servlets that are marked in the deployment descriptor to be loaded at server startup time.


logName

protected String logName()
Log the abbreviated name of this Container for logging messages.
Overrides:
logName in interface ContainerBase


registerJMX

protected void registerJMX(StandardContext ctx)


removeInitParameter

public void removeInitParameter(String name)
Remove the specified initialization parameter from this servlet.
Specified by:
removeInitParameter in interface Wrapper

Parameters:
name - Name of the initialization parameter to remove


removeInstanceListener

public void removeInstanceListener(InstanceListener listener)
Remove a listener no longer interested in InstanceEvents.
Specified by:
removeInstanceListener in interface Wrapper

Parameters:
listener - The listener to remove


removeMapping

public void removeMapping(String mapping)
Remove a mapping associated with the wrapper.
Specified by:
removeMapping in interface Wrapper

Parameters:
mapping - The pattern to remove


removeSecurityReference

public void removeSecurityReference(String name)
Remove any security role reference for the specified role name.
Specified by:
removeSecurityReference in interface Wrapper

Parameters:
name - Security role used within this servlet to be removed


setAvailable

public void setAvailable(long available)
Set the available date/time for this servlet, in milliseconds since the epoch. If this date/time is Long.MAX_VALUE, it is considered to mean that unavailability is permanent and any request for this servlet will return an SC_NOT_FOUND error. If this date/time is in the future, any request for this servlet will return an SC_SERVICE_UNAVAILABLE error.
Specified by:
setAvailable in interface Wrapper

Parameters:
available - The new available date/time


setDebug

public void setDebug(int debug)
Set the debugging detail level for this component.
Overrides:
setDebug in interface ContainerBase

Parameters:
debug - The new debugging detail level


setErrorCount

public void setErrorCount(int errorCount)


setJspFile

public void setJspFile(String jspFile)
Set the context-relative URI of the JSP file for this servlet.
Specified by:
setJspFile in interface Wrapper

Parameters:
jspFile - JSP file URI


setLoadOnStartup

public void setLoadOnStartup(int value)
Set the load-on-startup order value (negative value means load on first call).
Specified by:
setLoadOnStartup in interface Wrapper

Parameters:
value - New load-on-startup value


setLoadOnStartupString

public void setLoadOnStartupString(String value)
Set the load-on-startup order value from a (possibly null) string. Per the specification, any missing or non-numeric value is converted to a zero, so that this servlet will still be loaded at startup time, but in an arbitrary order.

Parameters:
value - New load-on-startup value


setLoadTime

public void setLoadTime(long loadTime)


setMaxInstances

public void setMaxInstances(int maxInstances)
Set the maximum number of instances that will be allocated when a single thread model servlet is used.

Parameters:
maxInstances - New value of maxInstances


setMaxTime

public void setMaxTime(long maxTime)


setMinTime

public void setMinTime(long minTime)


setParent

public void setParent(Container container)
Set the parent Container of this Wrapper, but only if it is a Context.
Specified by:
setParent in interface Container
Overrides:
setParent in interface ContainerBase

Parameters:
container - Proposed parent Container


setProcessingTime

public void setProcessingTime(long processingTime)


setRequestCount

public void setRequestCount(int requestCount)


setRunAs

public void setRunAs(String runAs)
Set the run-as identity for this servlet.
Specified by:
setRunAs in interface Wrapper

Parameters:
runAs - New run-as identity value


setServletClass

public void setServletClass(String servletClass)
Set the fully qualified servlet class name for this servlet.
Specified by:
setServletClass in interface Wrapper

Parameters:
servletClass - Servlet class name


setServletName

public void setServletName(String name)
Set the name of this servlet. This is an alias for the normal Container.setName() method, and complements the getServletName() method required by the ServletConfig interface.

Parameters:
name - The new name of this servlet


start

public void start()
            throws LifecycleException
Start this component, pre-loading the servlet if the load-on-startup value is set appropriately.
Specified by:
start in interface Lifecycle
Overrides:
start in interface ContainerBase

Throws:
LifecycleException - if a fatal error occurs during startup


stop

public void stop()
            throws LifecycleException
Stop this component, gracefully shutting down the servlet if it has been initialized.
Specified by:
stop in interface Lifecycle
Overrides:
stop in interface ContainerBase

Throws:
LifecycleException - if a fatal error occurs during shutdown


toString

public String toString()
Return a String representation of this component.


unavailable

public void unavailable(UnavailableException unavailable)
Process an UnavailableException, marking this servlet as unavailable for the specified amount of time.
Specified by:
unavailable in interface Wrapper

Parameters:
unavailable - The exception that occurred, or null to mark this servlet as permanently unavailable


unload

public void unload()
            throws ServletException
Unload all initialized instances of this servlet, after calling the destroy() method for each instance. This can be used, for example, prior to shutting down the entire servlet engine, or prior to reloading all of the classes from the Loader associated with our Loader's repository.
Specified by:
unload in interface Wrapper


Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.