@ManagedObject(value="Servlet Holder") public class ServletHolder extends Holder<javax.servlet.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 and Description |
---|---|
protected class |
ServletHolder.Config |
static class |
ServletHolder.JspContainer |
class |
ServletHolder.Registration |
Holder.HolderConfig, Holder.HolderRegistration
AbstractLifeCycle.AbstractLifeCycleListener
LifeCycle.Listener
Modifier and Type | Field and 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 |
_asyncSupported, _displayName, _initialized, _initParams, _name
_class, _className, _extInstance, _servletHandler, _source
Constructor and Description |
---|
ServletHolder()
Constructor .
|
ServletHolder(java.lang.Class<? extends javax.servlet.Servlet> servlet)
Constructor for servlet class.
|
ServletHolder(javax.servlet.Servlet servlet)
Constructor for existing servlet.
|
ServletHolder(Source creator)
Constructor .
|
ServletHolder(java.lang.String name,
java.lang.Class<? extends javax.servlet.Servlet> servlet)
Constructor for servlet class.
|
ServletHolder(java.lang.String name,
javax.servlet.Servlet servlet)
Constructor for servlet class.
|
Modifier and Type | Method and 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() |
void |
dump(java.lang.Appendable out,
java.lang.String indent)
Dump this object (and children) into an Appendable using the provided indent after any new lines.
|
javax.servlet.Servlet |
ensureInstance()
Deprecated.
|
boolean |
equals(java.lang.Object o) |
java.lang.String |
getClassNameForJsp(java.lang.String jsp) |
ContextHandler |
getContextHandler() |
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) |
javax.servlet.ServletRegistration.Dynamic |
getRegistration() |
java.util.Map<java.lang.String,java.lang.String> |
getRoleRefMap() |
java.lang.String |
getRunAsRole() |
javax.servlet.Servlet |
getServlet()
Get the servlet.
|
javax.servlet.Servlet |
getServletInstance()
Get the servlet instance (no initialization done).
|
javax.servlet.UnavailableException |
getUnavailableException() |
java.lang.String |
getUserRoleLink(java.lang.String name)
get a user role link.
|
void |
handle(Request baseRequest,
javax.servlet.ServletRequest request,
javax.servlet.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 javax.servlet.Servlet |
newInstance() |
protected void |
prepare(Request baseRequest,
javax.servlet.ServletRequest request,
javax.servlet.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(javax.servlet.Servlet servlet) |
void |
setUserRoleLink(java.lang.String name,
java.lang.String link)
Link a user role.
|
java.lang.String |
toString() |
dump, getDisplayName, getInitParameter, getInitParameterNames, getInitParameters, getName, isAsyncSupported, setAsyncSupported, setClassName, setDisplayName, setHeldClass, setInitParameter, setInitParameters, setName
getClassName, getHeldClass, getServletHandler, getSource, illegalStateIfContextStarted, isInstance, setServletHandler
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getName
dump, dumpObject, dumpObjects, dumpSelf
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(javax.servlet.Servlet servlet)
servlet
- the servletpublic ServletHolder(java.lang.String name, java.lang.Class<? extends javax.servlet.Servlet> servlet)
name
- the name of the servletservlet
- the servlet classpublic ServletHolder(java.lang.String name, javax.servlet.Servlet servlet)
name
- the servlet nameservlet
- the servletpublic ServletHolder(java.lang.Class<? extends javax.servlet.Servlet> servlet)
servlet
- the servlet classpublic javax.servlet.UnavailableException getUnavailableException()
public void setServlet(javax.servlet.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<javax.servlet.Servlet>
java.lang.Exception
public void initialize() throws java.lang.Exception
BaseHolder
initialize
in class BaseHolder<javax.servlet.Servlet>
java.lang.Exception
- if unable to initializepublic void doStop() throws java.lang.Exception
doStop
in class BaseHolder<javax.servlet.Servlet>
java.lang.Exception
public void destroyInstance(java.lang.Object o) throws java.lang.Exception
destroyInstance
in class Holder<javax.servlet.Servlet>
java.lang.Exception
public javax.servlet.Servlet getServlet() throws javax.servlet.ServletException
javax.servlet.ServletException
- if unable to init the servlet on first usepublic javax.servlet.Servlet getServletInstance()
public void checkServletType() throws javax.servlet.UnavailableException
javax.servlet.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 ContextHandler getContextHandler()
getContextHandler
in interface UserIdentity.Scope
public 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, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response) throws javax.servlet.ServletException, javax.servlet.UnavailableException
baseRequest
- the base requestrequest
- the requestresponse
- the responsejavax.servlet.ServletException
- if unable to prepare the servletjavax.servlet.UnavailableException
- if not available@Deprecated public javax.servlet.Servlet ensureInstance() throws javax.servlet.ServletException, javax.servlet.UnavailableException
javax.servlet.ServletException
javax.servlet.UnavailableException
public void handle(Request baseRequest, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response) throws javax.servlet.ServletException, javax.servlet.UnavailableException, java.io.IOException
baseRequest
- the base requestrequest
- the requestresponse
- the responsejavax.servlet.ServletException
- if unable to process the servletjavax.servlet.UnavailableException
- 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 javax.servlet.ServletRegistration.Dynamic getRegistration()
protected javax.servlet.Servlet newInstance() throws javax.servlet.ServletException, java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
javax.servlet.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 exceptionpublic void dump(java.lang.Appendable out, java.lang.String indent) throws java.io.IOException
Dumpable
dump
in interface Dumpable
dump
in class BaseHolder<javax.servlet.Servlet>
out
- The appendable to dump toindent
- The indent to apply after any new lines.java.io.IOException
- if unable to write to AppendableCopyright © 1995–2023 Webtide. All rights reserved.