java.lang.Comparable<ServletHolder>
, UserIdentity.Scope
, Dumpable
, LifeCycle
AntWebAppContext.AntServletHolder
@ManagedObject("Servlet Holder") public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope, java.lang.Comparable<ServletHolder>
Holds the name, params and some state of a javax.servlet.Servlet instance. It implements the ServletConfig interface. This class will organise the loading of the servlet when needed or requested.
Modifier and Type | Class | Description |
---|---|---|
protected class |
ServletHolder.Config |
|
static class |
ServletHolder.JspContainer |
|
class |
ServletHolder.Registration |
AbstractLifeCycle.AbstractLifeCycleListener
Holder.HolderConfig, Holder.HolderRegistration
LifeCycle.Listener
Modifier and Type | Field | Description |
---|---|---|
static java.lang.String |
APACHE_SENTINEL_CLASS |
|
static java.lang.String |
JSP_GENERATED_PACKAGE_NAME |
|
static java.util.Map<java.lang.String,java.lang.String> |
NO_MAPPED_ROLES |
FAILED, RUNNING, STARTED, STARTING, STOP_ON_FAILURE, STOPPED, STOPPING
_class, _className, _extInstance, _servletHandler, _source
_asyncSupported, _displayName, _initialized, _initParams, _name
Constructor | Description |
---|---|
ServletHolder() |
Constructor .
|
ServletHolder(java.lang.Class<? extends Servlet> servlet) |
Constructor for servlet class.
|
ServletHolder(java.lang.String name,
java.lang.Class<? extends Servlet> servlet) |
Constructor for servlet class.
|
ServletHolder(java.lang.String name,
Servlet servlet) |
Constructor for servlet class.
|
ServletHolder(Servlet servlet) |
Constructor for existing servlet.
|
ServletHolder(Source creator) |
Constructor .
|
Modifier and Type | Method | Description |
---|---|---|
protected void |
appendPath(java.lang.StringBuffer path,
java.lang.String element) |
Concatenate an element on to fully qualified classname.
|
void |
checkServletType() |
Check to ensure class of servlet is acceptable.
|
int |
compareTo(ServletHolder sh) |
Comparator by init order.
|
void |
destroyInstance(java.lang.Object o) |
|
void |
doStart() |
|
void |
doStop() |
|
Servlet |
ensureInstance() |
Deprecated.
|
boolean |
equals(java.lang.Object o) |
|
java.lang.String |
getClassNameForJsp(java.lang.String jsp) |
|
java.lang.String |
getContextPath() |
|
java.lang.String |
getForcedPath() |
|
int |
getInitOrder() |
|
java.lang.String |
getJspPackagePrefix() |
|
java.lang.String |
getNameOfJspClass(java.lang.String jsp) |
|
java.lang.String |
getPackageOfJspClass(java.lang.String jsp) |
|
ServletRegistration.Dynamic |
getRegistration() |
|
java.util.Map<java.lang.String,java.lang.String> |
getRoleRefMap() |
|
java.lang.String |
getRunAsRole() |
|
Servlet |
getServlet() |
Get the servlet.
|
Servlet |
getServletInstance() |
Get the servlet instance (no initialization done).
|
UnavailableException |
getUnavailableException() |
|
java.lang.String |
getUserRoleLink(java.lang.String name) |
get a user role link.
|
void |
handle(Request baseRequest,
ServletRequest request,
ServletResponse response) |
Service a request with this servlet.
|
int |
hashCode() |
|
void |
initialize() |
Do any setup necessary after starting
|
protected void |
initJspServlet() |
|
protected void |
initMultiPart() |
Register a ServletRequestListener that will ensure tmp multipart
files are deleted when the request goes out of scope.
|
boolean |
isAvailable() |
|
boolean |
isEnabled() |
|
protected boolean |
isJspServlet() |
|
protected boolean |
isJspServlet(java.lang.String classname) |
|
protected Servlet |
newInstance() |
|
protected void |
prepare(Request baseRequest,
ServletRequest request,
ServletResponse response) |
Prepare to service a request.
|
void |
setEnabled(boolean enabled) |
|
void |
setForcedPath(java.lang.String forcedPath) |
|
void |
setInitOrder(int order) |
Set the initialize order.
|
void |
setRunAsRole(java.lang.String role) |
|
void |
setServlet(Servlet servlet) |
|
void |
setUserRoleLink(java.lang.String name,
java.lang.String link) |
Link a user role.
|
java.lang.String |
toString() |
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop
getClassName, getHeldClass, getServletHandler, getSource, illegalStateIfContextStarted, isInstance, setServletHandler
dump, dump, getDisplayName, getInitParameter, getInitParameterNames, getInitParameters, getName, isAsyncSupported, setAsyncSupported, setClassName, setDisplayName, setHeldClass, setInitParameter, setInitParameters, setName
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getName
public static final java.lang.String APACHE_SENTINEL_CLASS
public static final java.lang.String JSP_GENERATED_PACKAGE_NAME
public static final java.util.Map<java.lang.String,java.lang.String> NO_MAPPED_ROLES
public ServletHolder()
public ServletHolder(Source creator)
creator
- the holder sourcepublic ServletHolder(Servlet servlet)
servlet
- the servletpublic ServletHolder(java.lang.String name, java.lang.Class<? extends Servlet> servlet)
name
- the name of the servletservlet
- the servlet classpublic ServletHolder(java.lang.String name, Servlet servlet)
name
- the servlet nameservlet
- the servletpublic ServletHolder(java.lang.Class<? extends Servlet> servlet)
servlet
- the servlet classpublic UnavailableException getUnavailableException()
public void setServlet(Servlet servlet)
@ManagedAttribute(value="initialization order", readonly=true) public int getInitOrder()
public void setInitOrder(int order)
Holders with order<0, are initialized on use. Those with order>=0 are initialized in increasing order when the handler is started.
order
- the servlet init orderpublic int compareTo(ServletHolder sh)
compareTo
in interface java.lang.Comparable<ServletHolder>
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public void setUserRoleLink(java.lang.String name, java.lang.String link)
name
- The role name as used by the servletlink
- The role name as used by the container.public java.lang.String getUserRoleLink(java.lang.String name)
name
- The name of the role@ManagedAttribute(value="forced servlet path", readonly=true) public java.lang.String getForcedPath()
public void setForcedPath(java.lang.String forcedPath)
forcedPath
- The forcedPath to set.public boolean isEnabled()
public void setEnabled(boolean enabled)
public void doStart() throws java.lang.Exception
doStart
in class BaseHolder<Servlet>
java.lang.Exception
public void initialize() throws java.lang.Exception
BaseHolder
initialize
in class BaseHolder<Servlet>
java.lang.Exception
- if unable to initializepublic void doStop() throws java.lang.Exception
doStop
in class BaseHolder<Servlet>
java.lang.Exception
public void destroyInstance(java.lang.Object o) throws java.lang.Exception
destroyInstance
in class Holder<Servlet>
java.lang.Exception
public Servlet getServlet() throws ServletException
ServletException
- if unable to init the servlet on first usepublic Servlet getServletInstance()
public void checkServletType() throws UnavailableException
UnavailableException
- if Servlet class is not of type Servlet
public boolean isAvailable()
protected void initJspServlet() throws java.lang.Exception
java.lang.Exception
- if unable to init the JSP Servletprotected void initMultiPart() throws java.lang.Exception
java.lang.Exception
- if unable to init the multipartpublic java.lang.String getContextPath()
getContextPath
in interface UserIdentity.Scope
UserIdentity.Scope.getContextPath()
public java.util.Map<java.lang.String,java.lang.String> getRoleRefMap()
getRoleRefMap
in interface UserIdentity.Scope
UserIdentity.Scope.getRoleRefMap()
@ManagedAttribute(value="role to run servlet as", readonly=true) public java.lang.String getRunAsRole()
public void setRunAsRole(java.lang.String role)
protected void prepare(Request baseRequest, ServletRequest request, ServletResponse response) throws ServletException, UnavailableException
baseRequest
- the base requestrequest
- the requestresponse
- the responseServletException
- if unable to prepare the servletUnavailableException
- if not available@Deprecated public Servlet ensureInstance() throws ServletException, UnavailableException
ServletException
UnavailableException
public void handle(Request baseRequest, ServletRequest request, ServletResponse response) throws ServletException, UnavailableException, java.io.IOException
baseRequest
- the base requestrequest
- the requestresponse
- the responseServletException
- if unable to process the servletUnavailableException
- if servlet is unavailablejava.io.IOException
- if unable to process the request or responseprotected boolean isJspServlet()
protected boolean isJspServlet(java.lang.String classname)
public java.lang.String getNameOfJspClass(java.lang.String jsp)
jsp
- the jsp-filepublic java.lang.String getPackageOfJspClass(java.lang.String jsp)
public java.lang.String getJspPackagePrefix()
public java.lang.String getClassNameForJsp(java.lang.String jsp)
jsp
- the jsp-file from web.xmlprotected void appendPath(java.lang.StringBuffer path, java.lang.String element)
path
- the path under constructionelement
- the element of the name to addpublic ServletRegistration.Dynamic getRegistration()
protected Servlet newInstance() throws ServletException, java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
ServletException
- if unable to create a new instancejava.lang.IllegalAccessException
- if not allowed to create a new instancejava.lang.InstantiationException
- if creating new instance resulted in errorjava.lang.NoSuchMethodException
- if creating new instance resulted in errorjava.lang.reflect.InvocationTargetException
- If creating new instance throws an exceptionCopyright © 1995–2018 Webtide. All rights reserved.