public interface Wrapper extends Container
Implementations of Wrapper are responsible for managing the servlet life cycle for their underlying servlet class, including calling init() and destroy() at appropriate times, as well as respecting the existence of the SingleThreadModel declaration on the servlet class itself.
The parent Container attached to a Wrapper will generally be an implementation of Context, representing the servlet context (and therefore the web application) within which this servlet executes.
Child Containers are not allowed on Wrapper implementations, so the
addChild()
method should throw an
IllegalArgumentException
.
Lifecycle.SingleUse
Modifier and Type | Field and Description |
---|---|
static String |
ADD_MAPPING_EVENT
Container event for adding a wrapper.
|
static String |
REMOVE_MAPPING_EVENT
Container event for removing a wrapper.
|
ADD_CHILD_EVENT, ADD_MAPPER_EVENT, ADD_VALVE_EVENT, REMOVE_CHILD_EVENT, REMOVE_MAPPER_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
Modifier and Type | Method and Description |
---|---|
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) |
String[] |
findInitParameters() |
String[] |
findMappings() |
String |
findSecurityReference(String name) |
String[] |
findSecurityReferences() |
long |
getAvailable() |
int |
getLoadOnStartup() |
MultipartConfigElement |
getMultipartConfigElement() |
String |
getRunAs() |
Servlet |
getServlet() |
String |
getServletClass() |
String[] |
getServletMethods()
Gets the names of the methods supported by the underlying servlet.
|
void |
incrementErrorCount()
Increment the error count value used when monitoring.
|
boolean |
isAsyncSupported()
Does the associated Servlet support async processing?
|
boolean |
isEnabled()
Is the associated Servlet enabled?
|
boolean |
isOverridable()
Is the Servlet overridable by a ServletContainerInitializer?
|
boolean |
isUnavailable() |
void |
load()
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 |
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 |
servletSecurityAnnotationScan()
Deprecated.
This will be removed in Tomcat 9.
|
void |
setAsyncSupported(boolean asyncSupport)
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 |
setMultipartConfigElement(MultipartConfigElement multipartConfig)
Set the multi-part configuration for the associated Servlet.
|
void |
setOverridable(boolean overridable)
Sets the overridable attribute for this Servlet.
|
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 |
setServletSecurityAnnotationScanRequired(boolean b)
Deprecated.
This will be removed in Tomcat 9.
|
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. |
addChild, addContainerListener, addPropertyChangeListener, backgroundProcess, findChild, findChildren, findContainerListeners, fireContainerEvent, getAccessLog, getBackgroundProcessorDelay, getCluster, getInfo, getLoader, getLogger, getManager, getMappingObject, getName, getObjectName, getParent, getParentClassLoader, getPipeline, getRealm, getResources, getStartStopThreads, invoke, logAccess, removeChild, removeContainerListener, removePropertyChangeListener, setBackgroundProcessorDelay, setCluster, setLoader, setManager, setName, setParent, setParentClassLoader, setRealm, setResources, setStartStopThreads
addLifecycleListener, destroy, findLifecycleListeners, getState, getStateName, init, removeLifecycleListener, start, stop
static final String ADD_MAPPING_EVENT
static final String REMOVE_MAPPING_EVENT
long getAvailable()
void setAvailable(long available)
available
- The new available date/timeint getLoadOnStartup()
void setLoadOnStartup(int value)
value
- New load-on-startup valueString getRunAs()
void setRunAs(String runAs)
runAs
- New run-as identity valueString getServletClass()
void setServletClass(String servletClass)
servletClass
- Servlet class nameString[] getServletMethods() throws ServletException
ServletException
- If the target servlet cannot be loadedboolean isUnavailable()
true
if this Servlet is currently unavailable.Servlet getServlet()
void setServlet(Servlet servlet)
servlet
- The associated Servletvoid addInitParameter(String name, String value)
name
- Name of this initialization parameter to addvalue
- Value of this initialization parameter to addvoid addInstanceListener(InstanceListener listener)
listener
- The new listenervoid addMapping(String mapping)
mapping
- The new wrapper mappingvoid addSecurityReference(String name, String link)
name
- Role name used within this servletlink
- Role name used within the web applicationServlet 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()
.ServletException
- if the Servlet init() method threw
an exceptionServletException
- if a loading error occursvoid deallocate(Servlet servlet) throws ServletException
servlet
- The servlet to be returnedServletException
- if a deallocation error occursString findInitParameter(String name)
name
- Name of the requested initialization parameternull
.String[] findInitParameters()
String[] findMappings()
String findSecurityReference(String name)
name
- Security role reference used within this servletnull
.String[] findSecurityReferences()
void incrementErrorCount()
void load() throws ServletException
ServletException
- if the Servlet init() method threw
an exception or if some other loading problem occursvoid removeInitParameter(String name)
name
- Name of the initialization parameter to removevoid removeInstanceListener(InstanceListener listener)
listener
- The listener to removevoid removeMapping(String mapping)
mapping
- The pattern to removevoid removeSecurityReference(String name)
name
- Security role used within this servlet to be removedvoid unavailable(UnavailableException unavailable)
unavailable
- The exception that occurred, or null
to mark this Servlet as permanently unavailablevoid 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.ServletException
- if an unload error occursMultipartConfigElement getMultipartConfigElement()
null
will be
returned.void setMultipartConfigElement(MultipartConfigElement multipartConfig)
null
as the new value.multipartConfig
- The configuration associated with the Servletboolean isAsyncSupported()
false
.true
if the Servlet supports asyncvoid setAsyncSupported(boolean asyncSupport)
asyncSupport
- the new valueboolean isEnabled()
true
.true
if the Servlet is enabledvoid setEnabled(boolean enabled)
enabled
- the new value@Deprecated void setServletSecurityAnnotationScanRequired(boolean b)
b
- Unused.@Deprecated void servletSecurityAnnotationScan() throws ServletException
ServletException
- Never thrownboolean isOverridable()
true
if the Servlet can be overridden in a ServletContainerInitializervoid setOverridable(boolean overridable)
overridable
- the new valueCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.