public class StandardWrapper extends ContainerBase implements ServletConfig, Wrapper, javax.management.NotificationEmitter
ContainerBase.ContainerBackgroundProcessor, ContainerBase.PrivilegedAddChild
Lifecycle.SingleUse
Modifier and Type | Field 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 javax.management.NotificationBroadcasterSupport |
broadcaster
The broadcaster that sends j2ee notifications.
|
protected int |
classLoadTime |
protected static java.lang.Class<?>[] |
classType
Static class array used when the SecurityManager is turned on and
Servlet.init is invoked. |
protected java.util.concurrent.atomic.AtomicInteger |
countAllocated
The count of allocations that are currently active (even if they
are for the same instance, as will be true on a non-STM servlet).
|
protected static java.lang.String[] |
DEFAULT_SERVLET_METHODS |
protected boolean |
enabled
Enabled
|
protected StandardWrapperFacade |
facade
The facade associated with this wrapper.
|
protected Servlet |
instance
The (single) possibly uninitialized instance of this servlet.
|
protected boolean |
instanceInitialized
Flag that indicates if this instance has been initialized
|
protected java.util.Stack<Servlet> |
instancePool
Stack containing the STM instances.
|
protected InstanceSupport |
instanceSupport
Deprecated.
Will be removed in 8.5.x onwards
|
protected boolean |
isJspServlet
True if this StandardWrapper is for the JspServlet
|
protected javax.management.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 |
loadTime |
protected java.util.ArrayList<java.lang.String> |
mappings
Mappings associated with the wrapper.
|
protected int |
maxInstances
Maximum number of STM instances.
|
protected MultipartConfigElement |
multipartConfigElement
Multipart config
|
protected int |
nInstances
Number of instances currently loaded for a STM servlet.
|
protected javax.management.MBeanNotificationInfo[] |
notificationInfo |
protected java.util.HashMap<java.lang.String,java.lang.String> |
parameters
The initialization parameters for this servlet, keyed by
parameter name.
|
protected java.util.HashMap<java.lang.String,java.lang.String> |
references
The security role references for this servlet, keyed by role name
used in the servlet.
|
protected java.lang.String |
runAs
The run-as identity for this servlet.
|
protected long |
sequenceNumber
The notification sequence number.
|
protected java.lang.String |
servletClass
The fully qualified servlet class name for this servlet.
|
protected boolean |
singleThreadModel
Does this servlet implement the SingleThreadModel interface?
|
protected boolean |
swallowOutput
Should we swallow System.out
|
protected org.apache.catalina.core.StandardWrapperValve |
swValve |
protected long |
unloadDelay
Wait time for servlet unload in ms.
|
protected boolean |
unloading
Are we unloading our servlet instance at the moment?
|
accessLog, backgroundProcessorDelay, children, cluster, listeners, logger, logName, name, parent, parentClassLoader, pipeline, sm, startChildren, startStopExecutor, support
mserver
ADD_MAPPING_EVENT, REMOVE_MAPPING_EVENT
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 |
---|
StandardWrapper()
Create a new StandardWrapper component with the default basic Valve.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(Container child)
Refuse to add a child Container, because Wrappers are the lowest level
of the Container hierarchy.
|
void |
addInitParameter(java.lang.String name,
java.lang.String value)
Add a new servlet initialization parameter for this servlet.
|
void |
addInstanceListener(InstanceListener listener)
Deprecated.
Will be removed in 8.5.x onwards
|
void |
addMapping(java.lang.String mapping)
Add a mapping associated with the Wrapper.
|
void |
addNotificationListener(javax.management.NotificationListener listener,
javax.management.NotificationFilter filter,
java.lang.Object object) |
void |
addSecurityReference(java.lang.String name,
java.lang.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 |
backgroundProcess()
Execute a periodic task, such as reloading, etc.
|
void |
deallocate(Servlet servlet)
Return this previously allocated servlet to the pool of available
instances.
|
java.lang.String |
findInitParameter(java.lang.String name)
Return the value for the specified initialization parameter name,
if any; otherwise return
null . |
java.lang.String[] |
findInitParameters()
Return the names of all defined initialization parameters for this
servlet.
|
java.lang.String[] |
findMappings()
Return the mappings associated with this wrapper.
|
java.lang.String |
findSecurityReference(java.lang.String name)
Return the security role link for the specified security role
reference name, if any; otherwise return
null . |
java.lang.String[] |
findSecurityReferences()
Return the set of security role reference names associated with
this servlet, if any; otherwise return a zero-length array.
|
protected java.lang.reflect.Method[] |
getAllDeclaredMethods(java.lang.Class<?> c) |
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 |
getErrorCount() |
java.lang.String |
getInitParameter(java.lang.String name)
Return the initialization parameter value for the specified name,
if any; otherwise return
null . |
java.util.Enumeration<java.lang.String> |
getInitParameterNames()
Return the set of initialization parameter names defined for this
servlet.
|
InstanceSupport |
getInstanceSupport()
Deprecated.
Will be removed in 8.5.x onwards
|
int |
getLoadOnStartup()
Return the load-on-startup order value (negative value means
load on first call).
|
java.lang.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() |
MultipartConfigElement |
getMultipartConfigElement()
Get the multi-part configuration for the associated servlet.
|
javax.management.MBeanNotificationInfo[] |
getNotificationInfo() |
protected java.lang.String |
getObjectNameKeyProperties()
Allow sub-classes to specify the key properties component of the
ObjectName that will be used to register this component. |
long |
getProcessingTime() |
int |
getRequestCount() |
static java.lang.Throwable |
getRootCause(ServletException e)
Extract the root cause from a servlet exception.
|
java.lang.String |
getRunAs()
Return the run-as identity for this servlet.
|
Servlet |
getServlet()
Return the associated servlet instance.
|
java.lang.String |
getServletClass()
Return the fully qualified servlet class name for this servlet.
|
ServletContext |
getServletContext()
Return the servlet context with which this servlet is associated.
|
java.lang.String[] |
getServletMethods()
Gets the names of the methods supported by the underlying servlet.
|
java.lang.String |
getServletName()
Return the name of this servlet.
|
void |
incrementErrorCount()
Increment the error count used for monitoring.
|
boolean |
isAsyncSupported()
Does the associated Servlet support async processing?
|
protected boolean |
isContainerProvidedServlet(java.lang.String classname)
Return
true if the specified class name represents a
container provided servlet class that should be loaded by the
server class loader. |
boolean |
isEnabled()
Is the associated Servlet enabled?
|
boolean |
isOverridable()
Is the Servlet overridable by a ServletContainerInitializer?
|
java.lang.Boolean |
isSingleThreadModel()
Does the servlet class represented by this component implement the
SingleThreadModel interface? |
boolean |
isStateManageable()
Deprecated.
The JSR-77 implementation is incomplete and will be removed
in 8.5.x
|
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.
|
void |
removeInitParameter(java.lang.String name)
Remove the specified initialization parameter from this servlet.
|
void |
removeInstanceListener(InstanceListener listener)
Deprecated.
Will be removed in 8.5.x onwards
|
void |
removeMapping(java.lang.String mapping)
Remove a mapping associated with the wrapper.
|
void |
removeNotificationListener(javax.management.NotificationListener listener)
Remove a JMX-NotificationListener
|
void |
removeNotificationListener(javax.management.NotificationListener listener,
javax.management.NotificationFilter filter,
java.lang.Object object) |
void |
removeSecurityReference(java.lang.String name)
Remove any security role reference for the specified role name.
|
void |
servletSecurityAnnotationScan()
This method is no longer used.
|
void |
setAsyncSupported(boolean asyncSupported)
Set the async support for the associated servlet.
|
void |
setAvailable(long available)
Set the available date/time for this servlet, in milliseconds since the
epoch.
|
void |
setEnabled(boolean enabled)
Sets the enabled attribute for the associated servlet.
|
void |
setLoadOnStartup(int value)
Set the load-on-startup order value (negative value means
load on first call).
|
void |
setLoadOnStartupString(java.lang.String value)
Set the load-on-startup order value from a (possibly null) string.
|
void |
setMaxInstances(int maxInstances)
Set the maximum number of instances that will be allocated when a single
thread model servlet is used.
|
void |
setMultipartConfigElement(MultipartConfigElement multipartConfigElement)
Set the multi-part configuration for the associated servlet.
|
void |
setOverridable(boolean overridable)
Sets the overridable attribute for this Servlet.
|
void |
setParent(Container container)
Set the parent Container of this Wrapper, but only if it is a Context.
|
void |
setRunAs(java.lang.String runAs)
Set the run-as identity for this servlet.
|
void |
setServlet(Servlet servlet)
Set the associated servlet instance.
|
void |
setServletClass(java.lang.String servletClass)
Set the fully qualified servlet class name for this servlet.
|
void |
setServletName(java.lang.String name)
Set the name of this servlet.
|
void |
setServletSecurityAnnotationScanRequired(boolean b)
This method is no longer used.
|
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() . |
java.lang.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. |
addContainerListener, addPropertyChangeListener, addValve, destroyInternal, findChild, findChildren, findContainerListeners, fireContainerEvent, getAccessLog, getBackgroundProcessorDelay, getCatalinaBase, getCatalinaHome, getChildren, getCluster, getClusterInternal, getDomainInternal, getLogger, getLogName, getMBeanKeyProperties, getName, getParent, getParentClassLoader, getPipeline, getRealm, getRealmInternal, getStartChildren, getStartStopThreads, initInternal, logAccess, removeChild, removeContainerListener, removePropertyChangeListener, setBackgroundProcessorDelay, setCluster, setName, setParentClassLoader, setRealm, setStartChildren, setStartStopThreads, threadStart, threadStop
getDomain, getObjectName, 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, wait, wait, wait
addContainerListener, addPropertyChangeListener, findChild, findChildren, findContainerListeners, fireContainerEvent, getAccessLog, getBackgroundProcessorDelay, getCatalinaBase, getCatalinaHome, getCluster, getDomain, getLogger, getLogName, getMBeanKeyProperties, getName, getObjectName, getParent, getParentClassLoader, getPipeline, getRealm, getStartStopThreads, logAccess, removeChild, removeContainerListener, removePropertyChangeListener, setBackgroundProcessorDelay, setCluster, setName, setParentClassLoader, setRealm, setStartStopThreads
addLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stop
protected static final java.lang.String[] DEFAULT_SERVLET_METHODS
protected long available
protected final javax.management.NotificationBroadcasterSupport broadcaster
protected final java.util.concurrent.atomic.AtomicInteger countAllocated
protected final StandardWrapperFacade facade
protected volatile Servlet instance
protected volatile boolean instanceInitialized
@Deprecated protected final InstanceSupport instanceSupport
protected int loadOnStartup
protected final java.util.ArrayList<java.lang.String> mappings
protected java.util.HashMap<java.lang.String,java.lang.String> parameters
protected java.util.HashMap<java.lang.String,java.lang.String> references
protected java.lang.String runAs
protected long sequenceNumber
protected java.lang.String servletClass
protected volatile boolean singleThreadModel
protected volatile boolean unloading
protected int maxInstances
protected int nInstances
protected java.util.Stack<Servlet> instancePool
protected long unloadDelay
protected boolean isJspServlet
protected javax.management.ObjectName jspMonitorON
protected boolean swallowOutput
protected org.apache.catalina.core.StandardWrapperValve swValve
protected long loadTime
protected int classLoadTime
protected MultipartConfigElement multipartConfigElement
protected boolean asyncSupported
protected boolean enabled
protected static java.lang.Class<?>[] classType
Servlet.init
is invoked.protected javax.management.MBeanNotificationInfo[] notificationInfo
public StandardWrapper()
public boolean isOverridable()
Wrapper
isOverridable
in interface Wrapper
public void setOverridable(boolean overridable)
Wrapper
setOverridable
in interface Wrapper
public long getAvailable()
getAvailable
in interface Wrapper
public void setAvailable(long available)
setAvailable
in interface Wrapper
available
- The new available date/timepublic int getCountAllocated()
SingleThreadModel
.@Deprecated public InstanceSupport getInstanceSupport()
public int getLoadOnStartup()
getLoadOnStartup
in interface Wrapper
public void setLoadOnStartup(int value)
setLoadOnStartup
in interface Wrapper
value
- New load-on-startup valuepublic void setLoadOnStartupString(java.lang.String value)
value
- New load-on-startup valuepublic java.lang.String getLoadOnStartupString()
public int getMaxInstances()
public void setMaxInstances(int maxInstances)
maxInstances
- New value of maxInstancespublic void setParent(Container container)
setParent
in interface Container
setParent
in class ContainerBase
container
- Proposed parent Containerpublic java.lang.String getRunAs()
public void setRunAs(java.lang.String runAs)
public java.lang.String getServletClass()
getServletClass
in interface Wrapper
public void setServletClass(java.lang.String servletClass)
setServletClass
in interface Wrapper
servletClass
- Servlet class namepublic void setServletName(java.lang.String name)
Container.setName()
method, and complements the
getServletName()
method required by the
ServletConfig
interface.name
- The new name of this servletpublic java.lang.Boolean isSingleThreadModel()
SingleThreadModel
interface? This can only be determined
once the class is loaded. Calling this method will not trigger loading
the class since that may cause the application to behave unexpectedly.null
if the class has not been loaded, otherwise true
if the servlet does implement SingleThreadModel
and
false
if it does not.public boolean isUnavailable()
isUnavailable
in interface Wrapper
public java.lang.String[] getServletMethods() throws ServletException
Wrapper
getServletMethods
in interface Wrapper
ServletException
- If the target servlet can not be loadedpublic Servlet getServlet()
getServlet
in interface Wrapper
public void setServlet(Servlet servlet)
setServlet
in interface Wrapper
public void setServletSecurityAnnotationScanRequired(boolean b)
setServletSecurityAnnotationScanRequired
in interface Wrapper
b
- Unused.public void backgroundProcess()
backgroundProcess
in interface Container
backgroundProcess
in class ContainerBase
public static java.lang.Throwable getRootCause(ServletException e)
e
- The servlet exceptionpublic void addChild(Container child)
addChild
in interface Container
addChild
in class ContainerBase
child
- Child container to be addedpublic void addInitParameter(java.lang.String name, java.lang.String value)
addInitParameter
in interface Wrapper
name
- Name of this initialization parameter to addvalue
- Value of this initialization parameter to add@Deprecated public void addInstanceListener(InstanceListener listener)
addInstanceListener
in interface Wrapper
listener
- The new listenerpublic void addMapping(java.lang.String mapping)
addMapping
in interface Wrapper
mapping
- The new wrapper mappingpublic void addSecurityReference(java.lang.String name, java.lang.String link)
addSecurityReference
in interface Wrapper
name
- Role name used within this servletlink
- Role name used within the web applicationpublic Servlet allocate() throws ServletException
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()
.allocate
in interface Wrapper
ServletException
- if the servlet init() method threw
an exceptionServletException
- if a loading error occurspublic void deallocate(Servlet servlet) throws ServletException
deallocate
in interface Wrapper
servlet
- The servlet to be returnedServletException
- if a deallocation error occurspublic java.lang.String findInitParameter(java.lang.String name)
null
.findInitParameter
in interface Wrapper
name
- Name of the requested initialization parameterpublic java.lang.String[] findInitParameters()
findInitParameters
in interface Wrapper
public java.lang.String[] findMappings()
findMappings
in interface Wrapper
public java.lang.String findSecurityReference(java.lang.String name)
null
.findSecurityReference
in interface Wrapper
name
- Security role reference used within this servletpublic java.lang.String[] findSecurityReferences()
findSecurityReferences
in interface Wrapper
public void load() throws ServletException
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.
load
in interface Wrapper
ServletException
- if the servlet init() method threw
an exceptionServletException
- if some other loading problem occurspublic Servlet loadServlet() throws ServletException
ServletException
public void servletSecurityAnnotationScan() throws ServletException
servletSecurityAnnotationScan
in interface Wrapper
ServletException
- Never thrownpublic void removeInitParameter(java.lang.String name)
removeInitParameter
in interface Wrapper
name
- Name of the initialization parameter to remove@Deprecated public void removeInstanceListener(InstanceListener listener)
removeInstanceListener
in interface Wrapper
listener
- The listener to removepublic void removeMapping(java.lang.String mapping)
removeMapping
in interface Wrapper
mapping
- The pattern to removepublic void removeSecurityReference(java.lang.String name)
removeSecurityReference
in interface Wrapper
name
- Security role used within this servlet to be removedpublic java.lang.String toString()
toString
in class java.lang.Object
public void unavailable(UnavailableException unavailable)
unavailable
in interface Wrapper
unavailable
- The exception that occurred, or null
to mark this servlet as permanently unavailablepublic void unload() throws ServletException
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.unload
in interface Wrapper
ServletException
- if an exception is thrown by the
destroy() methodpublic java.lang.String getInitParameter(java.lang.String name)
null
.getInitParameter
in interface ServletConfig
name
- Name of the initialization parameter to retrieveString
containing the value of the initialization
parameterpublic java.util.Enumeration<java.lang.String> getInitParameterNames()
getInitParameterNames
in interface ServletConfig
Enumeration
of String
objects
containing the names of the servlet's initialization parameterspublic ServletContext getServletContext()
getServletContext
in interface ServletConfig
ServletContext
object, used by the caller to interact
with its servlet containerServletContext
public java.lang.String getServletName()
getServletName
in interface ServletConfig
public long getProcessingTime()
public long getMaxTime()
public long getMinTime()
public int getRequestCount()
public int getErrorCount()
public void incrementErrorCount()
incrementErrorCount
in interface Wrapper
public long getLoadTime()
public int getClassLoadTime()
public MultipartConfigElement getMultipartConfigElement()
Wrapper
null
will be
returned.getMultipartConfigElement
in interface Wrapper
public void setMultipartConfigElement(MultipartConfigElement multipartConfigElement)
Wrapper
null
as the new value.setMultipartConfigElement
in interface Wrapper
public boolean isAsyncSupported()
Wrapper
false
.isAsyncSupported
in interface Wrapper
public void setAsyncSupported(boolean asyncSupported)
Wrapper
setAsyncSupported
in interface Wrapper
public boolean isEnabled()
Wrapper
true
.public void setEnabled(boolean enabled)
Wrapper
setEnabled
in interface Wrapper
protected boolean isContainerProvidedServlet(java.lang.String classname)
true
if the specified class name represents a
container provided servlet class that should be loaded by the
server class loader.classname
- Name of the class to be checkedprotected java.lang.reflect.Method[] getAllDeclaredMethods(java.lang.Class<?> c)
protected void startInternal() throws LifecycleException
LifecycleBase.startInternal()
.startInternal
in class ContainerBase
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedprotected void stopInternal() throws LifecycleException
LifecycleBase.stopInternal()
.stopInternal
in class ContainerBase
LifecycleException
- if this component detects a fatal error
that prevents this component from being usedprotected java.lang.String getObjectNameKeyProperties()
LifecycleMBeanBase
ObjectName
that will be used to register this component.getObjectNameKeyProperties
in class LifecycleMBeanBase
ObjectName
@Deprecated public boolean isStateManageable()
public void removeNotificationListener(javax.management.NotificationListener listener, javax.management.NotificationFilter filter, java.lang.Object object) throws javax.management.ListenerNotFoundException
removeNotificationListener
in interface javax.management.NotificationEmitter
javax.management.ListenerNotFoundException
public javax.management.MBeanNotificationInfo[] getNotificationInfo()
getNotificationInfo
in interface javax.management.NotificationBroadcaster
public void addNotificationListener(javax.management.NotificationListener listener, javax.management.NotificationFilter filter, java.lang.Object object) throws java.lang.IllegalArgumentException
addNotificationListener
in interface javax.management.NotificationBroadcaster
java.lang.IllegalArgumentException
public void removeNotificationListener(javax.management.NotificationListener listener) throws javax.management.ListenerNotFoundException
removeNotificationListener
in interface javax.management.NotificationBroadcaster
javax.management.ListenerNotFoundException
NotificationBroadcaster.removeNotificationListener(javax.management.NotificationListener)
Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.