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

public Class StandardWrapper

extends ContainerBase
implements ServletConfig, Wrapper, NotificationEmitter
Class Inheritance
All Implemented Interfaces
javax.management.NotificationEmitter, javax.management.NotificationBroadcaster, org.apache.catalina.Wrapper, org.apache.catalina.Container, org.apache.catalina.Lifecycle, jakarta.servlet.ServletConfig
Known Direct Subclasses
org.apache.catalina.startup.Tomcat.ExistingStandardWrapper
Imports
java.io.PrintStream, java.lang.reflect.Method, java.util.ArrayList, .Collections, .Enumeration, .HashMap, .HashSet, .Set, java.util.concurrent.atomic.AtomicInteger, java.util.concurrent.locks.ReentrantReadWriteLock, javax.management.ListenerNotFoundException, .MBeanNotificationInfo, .Notification, .NotificationBroadcasterSupport, .NotificationEmitter, .NotificationFilter, .NotificationListener, .ObjectName, jakarta.servlet.MultipartConfigElement, .Servlet, .ServletConfig, .ServletContext, .ServletException, .UnavailableException, jakarta.servlet.annotation.MultipartConfig, org.apache.catalina.Container, .ContainerServlet, .Context, .Globals, .LifecycleException, .LifecycleState, .Wrapper, org.apache.catalina.security.SecurityUtil, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.InstanceManager, .PeriodicEventListener, org.apache.tomcat.util.ExceptionUtils, org.apache.tomcat.util.log.SystemLogHandler, org.apache.tomcat.util.modeler.Registry, .Util

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.
Authors
Craig R. McClanahan, Remy Maucherat

Field Summary

Modifier and TypeField and Description
protected boolean
asyncSupported

Async support

protected long
available

The date and time at which this servlet will become available (in milliseconds since the epoch), or zero if the servlet is available.

protected final NotificationBroadcasterSupport
broadcaster

The broadcaster that sends j2ee notifications.

protected int
protected static Class<?>[]
classType

Static class array used when the SecurityManager is turned on and Servlet.init is invoked.

protected final AtomicInteger
countAllocated

The count of allocations that are currently active.

protected static final String[]
protected boolean
enabled

Enabled

protected final StandardWrapperFacade
facade

The facade associated with this wrapper.

protected volatile Servlet
instance

The (single) possibly uninitialized instance of this servlet.

protected volatile boolean
instanceInitialized

Flag that indicates if this instance has been initialized

protected boolean
isJspServlet

True if this StandardWrapper is for the JspServlet

protected ObjectName
jspMonitorON

The ObjectName of the JSP monitoring mbean

protected int
loadOnStartup

The load-on-startup order value (negative value means load on first call) for this servlet.

protected long
private final Log
protected final ArrayList<String>
mappings

Mappings associated with the wrapper.

private final ReentrantReadWriteLock
protected MultipartConfigElement
multipartConfigElement

Multipart config

protected MBeanNotificationInfo[]
private boolean
protected HashMap<String, String>
parameters

The initialization parameters for this servlet, keyed by parameter name.

private final ReentrantReadWriteLock
protected HashMap<String, String>
references

The security role references for this servlet, keyed by role name used in the servlet.

private final ReentrantReadWriteLock
protected String
runAs

The run-as identity for this servlet.

protected long
sequenceNumber

The notification sequence number.

protected String
servletClass

The fully qualified servlet class name for this servlet.

protected boolean
swallowOutput

Should we swallow System.out

protected StandardWrapperValve
protected long
unloadDelay

Wait time for servlet unload in ms.

protected volatile boolean
unloading

Are we unloading our servlet instance at the moment?

Inherited from org.apache.catalina.core.ContainerBase:
accessLogbackgroundProcessorDelaybackgroundProcessorFuturechildrenclusterlistenersloggerlogNamemonitorFuturenameparentparentClassLoaderpipelinesmstartChildrenstartStopExecutorsupport

Constructor Summary

AccessConstructor and Description
public
StandardWrapper()

Create a new StandardWrapper component with the default basic Valve.

Method Summary

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

Overrides org.apache.catalina.core.ContainerBase.addChild.

Implements org.apache.catalina.Container.addChild.

Refuse to add a child Container, because Wrappers are the lowest level of the Container hierarchy.

public void
addInitParameter(String
Name of this initialization parameter to add
name
,
String
Value of this initialization parameter to add
value
)

Implements org.apache.catalina.Wrapper.addInitParameter.

Add a new servlet initialization parameter for this servlet.

public void
addMapping(String
The new wrapper mapping
mapping
)

Implements org.apache.catalina.Wrapper.addMapping.

Add a mapping associated with the Wrapper.

public void
addNotificationListener(NotificationListener
The listener object which will handle the notifications emitted by the broadcaster.
listener
,
NotificationFilter
The filter object. If filter is null, no filtering will be performed before handling notifications.
filter
,
Object
An opaque object to be sent back to the listener when a notification is emitted. This object cannot be used by the Notification broadcaster object. It should be resent unchanged with the notification to the listener.
object
)

Implements javax.management.NotificationBroadcaster.addNotificationListener.

Add a JMX-NotificationListener

public void
addSecurityReference(String
Role name used within this servlet
name
,
String
Role name used within the web application
link
)

Implements org.apache.catalina.Wrapper.addSecurityReference.

Add a new security role reference record to the set of records for this servlet.

public Servlet
allocate()

Implements org.apache.catalina.Wrapper.allocate.

Allocate an initialized instance of this Servlet that is ready to have its service() method called.

public synchronized void
backgroundProcess()

Overrides org.apache.catalina.core.ContainerBase.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.

public void
deallocate(Servlet
The servlet to be returned
servlet
)

Implements org.apache.catalina.Wrapper.deallocate.

Decrement the allocation count for this servlet.

public String
findInitParameter(String
Name of the requested initialization parameter
name
)

Implements org.apache.catalina.Wrapper.findInitParameter.

Return the value for the specified initialization parameter name, if any; otherwise return null.

public String[]
findInitParameters()

Implements org.apache.catalina.Wrapper.findInitParameters.

Return the names of all defined initialization parameters for this servlet.

public String[]
findMappings()

Implements org.apache.catalina.Wrapper.findMappings.

Return the mappings associated with this wrapper.

public String
findSecurityReference(String
Security role reference used within this servlet
name
)

Implements org.apache.catalina.Wrapper.findSecurityReference.

Return the security role link for the specified security role reference name, if any; otherwise return null.

public String[]
findSecurityReferences()

Implements org.apache.catalina.Wrapper.findSecurityReferences.

Return the set of security role reference names associated with this servlet, if any; otherwise return a zero-length array.

protected Method[]
public long
getAvailable()

Implements org.apache.catalina.Wrapper.getAvailable.

Return the available date/time for this servlet, in milliseconds since the epoch.

public int
public int

Returns:

the number of active allocations of this servlet.
getCountAllocated
()

public int

Returns:

the number of requests processed by the wrapper that resulted in an error.
getErrorCount
()
Deprecated The return type will change to long in Tomcat 11 onwards. Callers of this method should switch to storing the result of calls to this method in a long value rather than an int.

Returns the number of requests processed by the wrapper that resulted in an error.

public String

Returns:

the initialization parameter value for the specified name, if any; otherwise return null.
getInitParameter
(String
Name of the initialization parameter to retrieve
name
)

Implements jakarta.servlet.ServletConfig.getInitParameter.

Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist.

public Enumeration<String>

Returns:

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

Implements jakarta.servlet.ServletConfig.getInitParameterNames.

Returns the names of the servlet's initialization parameters as an Enumeration of String objects, or an empty Enumeration if the servlet has no initialization parameters.

private String
public int

Returns:

the load-on-startup order value (negative value means load on first call).
getLoadOnStartup
()

Implements org.apache.catalina.Wrapper.getLoadOnStartup.

public String

Returns:

the load-on-startup value that was parsed
getLoadOnStartupString
()

public long
public long
public long
public MultipartConfigElement
public MBeanNotificationInfo[]
protected String
getObjectNameKeyProperties()

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

Allow sub-classes to specify the key properties component of the ObjectName that will be used to register this component.

public long
public int

Returns:

the number of requests processed by the wrapper.
getRequestCount
()
Deprecated The return type will change to long in Tomcat 11 onwards. Callers of this method should switch to storing the result of calls to this method in a long value rather than an int.

Returns the number of requests processed by the wrapper.

public static Throwable

Returns:

the root cause of the Servlet exception
getRootCause
(ServletException
The servlet exception
e
)

Extract the root cause from a servlet exception.

public String

Returns:

the run-as identity for this servlet.
getRunAs
()

Implements org.apache.catalina.Wrapper.getRunAs.

public Servlet

Returns:

the associated servlet instance.
getServlet
()

Implements org.apache.catalina.Wrapper.getServlet.

public String

Returns:

the fully qualified servlet class name for this servlet.
getServletClass
()

Implements org.apache.catalina.Wrapper.getServletClass.

public ServletContext

Returns:

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

Implements jakarta.servlet.ServletConfig.getServletContext.

Returns a reference to the ServletContext in which the caller is executing.

public String[]
getServletMethods()

Implements org.apache.catalina.Wrapper.getServletMethods.

Gets the names of the methods supported by the underlying servlet.

public String

Returns:

the name of this servlet.
getServletName
()

Implements jakarta.servlet.ServletConfig.getServletName.

Returns the name of this servlet instance.

private String
public void
incrementErrorCount()

Implements org.apache.catalina.Wrapper.incrementErrorCount.

Increment the error count used for monitoring.

private synchronized void
public boolean
isAsyncSupported()

Implements org.apache.catalina.Wrapper.isAsyncSupported.

Does the associated Servlet support async processing?

public boolean
isEnabled()

Implements org.apache.catalina.Wrapper.isEnabled.

Is the associated Servlet enabled?

public boolean
isOverridable()

Implements org.apache.catalina.Wrapper.isOverridable.

Is the Servlet overridable by a ServletContainerInitializer?

public boolean

Returns:

true if the Servlet has been marked unavailable.
isUnavailable
()

Implements org.apache.catalina.Wrapper.isUnavailable.

public synchronized void
load()

Implements org.apache.catalina.Wrapper.load.

Load and initialize an instance of this servlet, if there is not already at least one initialized instance.

public synchronized Servlet

Returns:

the loaded Servlet instance
loadServlet
()

Load and initialize an instance of this servlet, if there is not already an initialized instance.

public void
removeInitParameter(String
Name of the initialization parameter to remove
name
)

Implements org.apache.catalina.Wrapper.removeInitParameter.

Remove the specified initialization parameter from this servlet.

public void
removeMapping(String
The pattern to remove
mapping
)

Implements org.apache.catalina.Wrapper.removeMapping.

Remove a mapping associated with the wrapper.

public void
removeNotificationListener(NotificationListener
A listener that was previously added to this MBean.
listener
,
NotificationFilter
The filter that was specified when the listener was added.
filter
,
Object
The handback that was specified when the listener was added.
object
)

Implements javax.management.NotificationEmitter.removeNotificationListener.

Remove a JMX notificationListener

public void
removeNotificationListener(NotificationListener
A listener that was previously added to this MBean.
listener
)

Implements javax.management.NotificationBroadcaster.removeNotificationListener.

Remove a JMX-NotificationListener

public void
removeSecurityReference(String
Security role used within this servlet to be removed
name
)

Implements org.apache.catalina.Wrapper.removeSecurityReference.

Remove any security role reference for the specified role name.

public void
setAsyncSupported(boolean
the new value
asyncSupported
)

Implements org.apache.catalina.Wrapper.setAsyncSupported.

Set the async support for the associated Servlet.

public void
setAvailable(long
The new available date/time
available
)

Implements org.apache.catalina.Wrapper.setAvailable.

Set the available date/time for this servlet, in milliseconds since the epoch.

public void
setEnabled(boolean
the new value
enabled
)

Implements org.apache.catalina.Wrapper.setEnabled.

Sets the enabled attribute for the associated servlet.

public void
setLoadOnStartup(int
New load-on-startup value
value
)

Implements org.apache.catalina.Wrapper.setLoadOnStartup.

Set the load-on-startup order value (negative value means load on first call).

public void
setLoadOnStartupString(String
New load-on-startup value
value
)

Set the load-on-startup order value from a (possibly null) string.

public void
setMultipartConfigElement(MultipartConfigElement
The configuration associated with the Servlet
multipartConfigElement
)

Implements org.apache.catalina.Wrapper.setMultipartConfigElement.

Set the multi-part configuration for the associated Servlet.

public void
setOverridable(boolean
the new value
overridable
)

Implements org.apache.catalina.Wrapper.setOverridable.

Sets the overridable attribute for this Servlet.

public void
setParent(Container
Proposed parent Container
container
)

Overrides org.apache.catalina.core.ContainerBase.setParent.

Implements org.apache.catalina.Container.setParent.

Set the parent Container of this Wrapper, but only if it is a Context.

public void
setRunAs(String
New run-as identity value
runAs
)

Implements org.apache.catalina.Wrapper.setRunAs.

Set the run-as identity for this servlet.

public void
setServlet(Servlet
The associated Servlet
servlet
)

Implements org.apache.catalina.Wrapper.setServlet.

Set the associated servlet instance.

public void
setServletClass(String
Servlet class name
servletClass
)

Implements org.apache.catalina.Wrapper.setServletClass.

Set the fully qualified servlet class name for this servlet.

public void
setServletName(String
The new name of this servlet
name
)

Set the name of this servlet.

protected void
protected void
public void
unavailable(UnavailableException
The exception that occurred, or null to mark this servlet as permanently unavailable
unavailable
)

Implements org.apache.catalina.Wrapper.unavailable.

Process an UnavailableException, marking this servlet as unavailable for the specified amount of time.

public synchronized void
unload()

Implements org.apache.catalina.Wrapper.unload.

Unload all initialized instances of this servlet, after calling the destroy() method for each instance.

Inherited from org.apache.catalina.core.ContainerBase:
addContainerListeneraddPropertyChangeListeneraddValvedestroyInternalfindChildfindChildrenfindContainerListenersfireContainerEventgetAccessLoggetBackgroundProcessorDelaygetCatalinaBasegetCatalinaHomegetChildrengetClustergetClusterInternalgetDomainInternalgetLoggergetLogNamegetMBeanKeyPropertiesgetNamegetParentgetParentClassLoadergetPipelinegetRealmgetRealmInternalgetStartChildrengetStartStopThreadslogAccessremoveChildremoveContainerListenerremovePropertyChangeListenersetBackgroundProcessorDelaysetClustersetNamesetParentClassLoadersetRealmsetStartChildrensetStartStopThreadsthreadStartthreadStoptoString