org.apache.catalina

Interface Wrapper

public interface Wrapper extends Container

A Wrapper is a Container that represents an individual servlet definition from the deployment descriptor of the web application. It provides a convenient mechanism to use Interceptors that see every single request to the servlet represented by this definition.

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.

Version: $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (Tue, 24 Oct 2006) $

Author: Craig R. McClanahan

Method Summary
voidaddInitParameter(String name, String value)
Add a new servlet initialization parameter for this servlet.
voidaddInstanceListener(InstanceListener listener)
Add a new listener interested in InstanceEvents.
voidaddMapping(String mapping)
Add a mapping associated with the Wrapper.
voidaddSecurityReference(String name, String link)
Add a new security role reference record to the set of records for this servlet.
Servletallocate()
Allocate an initialized instance of this Servlet that is ready to have its service() method called.
voiddeallocate(Servlet servlet)
Return this previously allocated servlet to the pool of available instances.
StringfindInitParameter(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.
StringfindSecurityReference(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.
longgetAvailable()
Return the available date/time for this servlet, in milliseconds since the epoch.
StringgetJspFile()
Return the context-relative URI of the JSP file for this servlet.
intgetLoadOnStartup()
Return the load-on-startup order value (negative value means load on first call).
StringgetRunAs()
Return the run-as identity for this servlet.
ServletgetServlet()
Return the associated servlet instance.
StringgetServletClass()
Return the fully qualified servlet class name for this servlet.
String[]getServletMethods()
Gets the names of the methods supported by the underlying servlet.
voidincrementErrorCount()
Increment the error count value used when monitoring.
booleanisUnavailable()
Is this servlet currently unavailable?
voidload()
Load and initialize an instance of this servlet, if there is not already at least one initialized instance.
voidremoveInitParameter(String name)
Remove the specified initialization parameter from this servlet.
voidremoveInstanceListener(InstanceListener listener)
Remove a listener no longer interested in InstanceEvents.
voidremoveMapping(String mapping)
Remove a mapping associated with the wrapper.
voidremoveSecurityReference(String name)
Remove any security role reference for the specified role name.
voidsetAvailable(long available)
Set the available date/time for this servlet, in milliseconds since the epoch.
voidsetJspFile(String jspFile)
Set the context-relative URI of the JSP file for this servlet.
voidsetLoadOnStartup(int value)
Set the load-on-startup order value (negative value means load on first call).
voidsetRunAs(String runAs)
Set the run-as identity for this servlet.
voidsetServletClass(String servletClass)
Set the fully qualified servlet class name for this servlet.
voidunavailable(UnavailableException unavailable)
Process an UnavailableException, marking this servlet as unavailable for the specified amount of time.
voidunload()
Unload all initialized instances of this servlet, after calling the destroy() method for each instance.

Method Detail

addInitParameter

public void addInitParameter(String name, String value)
Add a new servlet initialization parameter for this servlet.

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.

Parameters: listener The new listener

addMapping

public void addMapping(String mapping)
Add a mapping associated with the 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.

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

allocate

public Servlet allocate()
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().

Throws: ServletException if the servlet init() method threw an exception ServletException if a loading error occurs

deallocate

public void deallocate(Servlet servlet)
Return this previously allocated servlet to the pool of available instances. If this servlet class does not implement SingleThreadModel, no action is actually required.

Parameters: servlet The servlet to be returned

Throws: ServletException if a deallocation error occurs

findInitParameter

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

Parameters: name Name of the requested initialization parameter

findInitParameters

public String[] findInitParameters()
Return the names of all defined initialization parameters for this servlet.

findMappings

public String[] findMappings()
Return the mappings associated with this wrapper.

findSecurityReference

public String findSecurityReference(String name)
Return the security role link for the specified security role reference name, if any; otherwise return null.

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.

getAvailable

public long getAvailable()
Return the available date/time for this servlet, in milliseconds since the epoch. 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. A value equal to Long.MAX_VALUE is considered to mean that unavailability is permanent.

getJspFile

public String getJspFile()
Return the context-relative URI of the JSP file for this servlet.

getLoadOnStartup

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

getRunAs

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

getServlet

public Servlet getServlet()
Return the associated servlet instance.

getServletClass

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

getServletMethods

public String[] getServletMethods()
Gets the names of the methods supported by the underlying servlet. This is the same set of methods included in the Allow response header in response to an OPTIONS request method processed by the underlying servlet.

Returns: Array of names of the methods supported by the underlying servlet

incrementErrorCount

public void incrementErrorCount()
Increment the error count value used when monitoring.

isUnavailable

public boolean isUnavailable()
Is this servlet currently unavailable?

load

public void load()
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.

Throws: ServletException if the servlet init() method threw an exception ServletException if some other loading problem occurs

removeInitParameter

public void removeInitParameter(String name)
Remove the specified initialization parameter from this servlet.

Parameters: name Name of the initialization parameter to remove

removeInstanceListener

public void removeInstanceListener(InstanceListener listener)
Remove a listener no longer interested in InstanceEvents.

Parameters: listener The listener to remove

removeMapping

public void removeMapping(String mapping)
Remove a mapping associated with the wrapper.

Parameters: mapping The pattern to remove

removeSecurityReference

public void removeSecurityReference(String name)
Remove any security role reference for the specified role name.

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 in the future, any request for this servlet will return an SC_SERVICE_UNAVAILABLE error. A value equal to Long.MAX_VALUE is considered to mean that unavailability is permanent.

Parameters: available The new available date/time

setJspFile

public void setJspFile(String jspFile)
Set the context-relative URI of the JSP file for this servlet.

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).

Parameters: value New load-on-startup value

setRunAs

public void setRunAs(String runAs)
Set the run-as identity for this servlet.

Parameters: runAs New run-as identity value

setServletClass

public void setServletClass(String servletClass)
Set the fully qualified servlet class name for this servlet.

Parameters: servletClass Servlet class name

unavailable

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

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

unload

public void unload()
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.

Throws: ServletException if an unload error occurs

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.