public class StandardWrapper extends ContainerBase implements ServletConfig, Wrapper, 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 NotificationBroadcasterSupport |
broadcaster
The broadcaster that sends j2ee notifications.
|
protected int |
classLoadTime |
protected static Class<?>[] |
classType
Static class array used when the SecurityManager is turned on and
Servlet.init is invoked. |
protected 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 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 Stack<Servlet> |
instancePool
Stack containing the STM instances.
|
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 |
loadTime |
protected ArrayList<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 MBeanNotificationInfo[] |
notificationInfo |
protected HashMap<String,String> |
parameters
The initialization parameters for this servlet, keyed by
parameter name.
|
protected HashMap<String,String> |
references
The security role references for this servlet, keyed by role name
used in the servlet.
|
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 |
servletSecurityAnnotationScanRequired |
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(String name,
String value)
Add a new servlet initialization parameter for this servlet.
|
void |
addMapping(String mapping)
Add a mapping associated with the Wrapper.
|
void |
addNotificationListener(NotificationListener listener,
NotificationFilter filter,
Object object)
Add a JMX-NotificationListener
|
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 |
backgroundProcess()
Execute a periodic task, such as reloading, etc.
|
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.
|
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.
|
protected Method[] |
getAllDeclaredMethods(Class<?> c) |
long |
getAvailable()
Return the available date/time for this servlet, in milliseconds since
the epoch.
|
int |
getClassLoadTime() |
int |
getCountAllocated() |
int |
getErrorCount() |
String |
getInitParameter(String name)
Returns a
String containing the value of the named
initialization parameter, or null if the parameter does not
exist. |
Enumeration<String> |
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. |
int |
getLoadOnStartup() |
String |
getLoadOnStartupString() |
long |
getLoadTime() |
int |
getMaxInstances() |
long |
getMaxTime() |
long |
getMinTime() |
MultipartConfigElement |
getMultipartConfigElement() |
MBeanNotificationInfo[] |
getNotificationInfo()
Get JMX Broadcaster Info
FIXME: This two events we not send j2ee.state.failed and j2ee.attribute.changed!
|
protected 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 Throwable |
getRootCause(ServletException e)
Extract the root cause from a servlet exception.
|
String |
getRunAs() |
Servlet |
getServlet() |
String |
getServletClass() |
ServletContext |
getServletContext()
Returns a reference to the
ServletContext in which the caller is
executing. |
String[] |
getServletMethods()
Gets the names of the methods supported by the underlying servlet.
|
String |
getServletName()
Returns the name of this servlet instance.
|
void |
incrementErrorCount()
Increment the error count used for monitoring.
|
boolean |
isAsyncSupported()
Does the associated Servlet support async processing?
|
protected boolean |
isContainerProvidedServlet(String classname) |
boolean |
isEnabled()
Is the associated Servlet enabled?
|
boolean |
isOverridable()
Is the Servlet overridable by a ServletContainerInitializer?
|
boolean |
isSingleThreadModel() |
boolean |
isUnavailable() |
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(String name)
Remove the specified initialization parameter from this servlet.
|
void |
removeMapping(String mapping)
Remove a mapping associated with the wrapper.
|
void |
removeNotificationListener(NotificationListener listener)
Remove a JMX-NotificationListener
|
void |
removeNotificationListener(NotificationListener listener,
NotificationFilter filter,
Object object)
Remove a JMX notficationListener
|
void |
removeSecurityReference(String name)
Remove any security role reference for the specified role name.
|
void |
servletSecurityAnnotationScan()
Scan for (if necessary) and process (if found) the
ServletSecurity annotations for the
Servlet associated with this wrapper. |
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(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(String runAs)
Set the run-as identity for this servlet.
|
void |
setServlet(Servlet servlet)
Set the associated servlet instance.
|
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 |
setServletSecurityAnnotationScanRequired(boolean b)
Set the flag that indicates
ServletSecurity annotations must be
scanned when the Servlet is first 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() . |
String |
toString() |
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, getMBeanKeyProperties, getName, getParent, getParentClassLoader, getPipeline, getRealm, getRealmInternal, getStartChildren, getStartStopThreads, initInternal, logAccess, logName, 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, 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 String[] DEFAULT_SERVLET_METHODS
protected long available
protected final NotificationBroadcasterSupport broadcaster
protected final AtomicInteger countAllocated
protected final StandardWrapperFacade facade
protected volatile Servlet instance
protected volatile boolean instanceInitialized
protected int loadOnStartup
protected HashMap<String,String> parameters
protected HashMap<String,String> references
protected String runAs
protected long sequenceNumber
protected String servletClass
protected volatile boolean singleThreadModel
protected volatile boolean unloading
protected int maxInstances
protected int nInstances
protected long unloadDelay
protected boolean isJspServlet
protected 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 volatile boolean servletSecurityAnnotationScanRequired
protected static Class<?>[] classType
Servlet.init
is invoked.protected MBeanNotificationInfo[] notificationInfo
public StandardWrapper()
public boolean isOverridable()
Wrapper
isOverridable
in interface Wrapper
true
if the Servlet can be overridden in a ServletContainerInitializerpublic void setOverridable(boolean overridable)
Wrapper
setOverridable
in interface Wrapper
overridable
- the new valuepublic long getAvailable()
getAvailable
in interface Wrapper
public void setAvailable(long available)
setAvailable
in interface Wrapper
available
- The new available date/timepublic int getCountAllocated()
SingleThreadModel
.public int getLoadOnStartup()
getLoadOnStartup
in interface Wrapper
public void setLoadOnStartup(int value)
setLoadOnStartup
in interface Wrapper
value
- New load-on-startup valuepublic void setLoadOnStartupString(String value)
value
- New load-on-startup valuepublic 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 String getRunAs()
public void setRunAs(String runAs)
public String getServletClass()
getServletClass
in interface Wrapper
public void setServletClass(String servletClass)
setServletClass
in interface Wrapper
servletClass
- Servlet class namepublic void setServletName(String name)
Container.setName()
method, and complements the
getServletName()
method required by the
ServletConfig
interface.name
- The new name of this servletpublic boolean isSingleThreadModel()
true
if the servlet class represented by this
component implements the SingleThreadModel
interface.public boolean isUnavailable()
isUnavailable
in interface Wrapper
true
if the Servlet has been marked unavailable.public String[] getServletMethods() throws ServletException
Wrapper
getServletMethods
in interface Wrapper
ServletException
- If the target servlet cannot be loadedpublic Servlet getServlet()
getServlet
in interface Wrapper
public void setServlet(Servlet servlet)
setServlet
in interface Wrapper
servlet
- The associated Servletpublic void setServletSecurityAnnotationScanRequired(boolean b)
ServletSecurity
annotations must be
scanned when the Servlet is first used.setServletSecurityAnnotationScanRequired
in interface Wrapper
b
- The new value of the flagpublic void backgroundProcess()
backgroundProcess
in interface Container
backgroundProcess
in class ContainerBase
public static 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(String name, String value)
addInitParameter
in interface Wrapper
name
- Name of this initialization parameter to addvalue
- Value of this initialization parameter to addpublic void addMapping(String mapping)
addMapping
in interface Wrapper
mapping
- The new wrapper mappingpublic void addSecurityReference(String name, 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 String findInitParameter(String name)
null
.findInitParameter
in interface Wrapper
name
- Name of the requested initialization parameternull
.public String[] findInitParameters()
findInitParameters
in interface Wrapper
public String[] findMappings()
findMappings
in interface Wrapper
public String findSecurityReference(String name)
null
.findSecurityReference
in interface Wrapper
name
- Security role reference used within this servletnull
.public 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
- for a Servlet load errorpublic void servletSecurityAnnotationScan() throws ServletException
ServletSecurity
annotations for the
Servlet associated with this wrapper.servletSecurityAnnotationScan
in interface Wrapper
ServletException
- if an annotation scanning error occurspublic void removeInitParameter(String name)
removeInitParameter
in interface Wrapper
name
- Name of the initialization parameter to removepublic void removeMapping(String mapping)
removeMapping
in interface Wrapper
mapping
- The pattern to removepublic void removeSecurityReference(String name)
removeSecurityReference
in interface Wrapper
name
- Security role used within this servlet to be removedpublic String toString()
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 String getInitParameter(String name)
javax.servlet.ServletConfig
String
containing the value of the named
initialization parameter, or null
if the parameter does not
exist.getInitParameter
in interface ServletConfig
name
- Name of the initialization parameter to retrievenull
.public Enumeration<String> getInitParameterNames()
javax.servlet.ServletConfig
Enumeration
of String
objects, or an empty
Enumeration
if the servlet has no initialization parameters.getInitParameterNames
in interface ServletConfig
public ServletContext getServletContext()
javax.servlet.ServletConfig
ServletContext
in which the caller is
executing.getServletContext
in interface ServletConfig
ServletContext
public String getServletName()
javax.servlet.ServletConfig
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()
getMultipartConfigElement
in interface Wrapper
null
will be
returned.public void setMultipartConfigElement(MultipartConfigElement multipartConfigElement)
Wrapper
null
as the new value.setMultipartConfigElement
in interface Wrapper
multipartConfigElement
- The configuration associated with the Servletpublic boolean isAsyncSupported()
Wrapper
false
.isAsyncSupported
in interface Wrapper
true
if the Servlet supports asyncpublic void setAsyncSupported(boolean asyncSupported)
Wrapper
setAsyncSupported
in interface Wrapper
asyncSupported
- the new valuepublic boolean isEnabled()
Wrapper
true
.public void setEnabled(boolean enabled)
Wrapper
setEnabled
in interface Wrapper
enabled
- the new valueprotected boolean isContainerProvidedServlet(String classname)
classname
- Name of the class to be checkedtrue
if the specified class name represents a
container provided servlet class that should be loaded by the
server class loader.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 String getObjectNameKeyProperties()
LifecycleMBeanBase
ObjectName
that will be used to register this component.getObjectNameKeyProperties
in class LifecycleMBeanBase
ObjectName
public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object object) throws ListenerNotFoundException
public MBeanNotificationInfo[] getNotificationInfo()
getNotificationInfo
in interface NotificationBroadcaster
NotificationBroadcaster.getNotificationInfo()
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object object) throws IllegalArgumentException
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException
removeNotificationListener
in interface NotificationBroadcaster
ListenerNotFoundException
NotificationBroadcaster.removeNotificationListener(javax.management.NotificationListener)
Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.