@ManagedObject(value="Servlet Holder") public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope, 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
BaseHolder.Source
AbstractLifeCycle.AbstractLifeCycleListener
LifeCycle.Listener
Modifier and Type | Field and Description |
---|---|
static String |
APACHE_SENTINEL_CLASS |
static String |
JSP_GENERATED_PACKAGE_NAME |
static Map<String,String> |
NO_MAPPED_ROLES |
_asyncSupported, _displayName, _initParams, _name
_class, _className, _extInstance, _servletHandler, _source
Constructor and Description |
---|
ServletHolder()
Constructor .
|
ServletHolder(BaseHolder.Source creator)
Constructor .
|
ServletHolder(Class<? extends Servlet> servlet)
Constructor for servlet class.
|
ServletHolder(Servlet servlet)
Constructor for existing servlet.
|
ServletHolder(String name,
Class<? extends Servlet> servlet)
Constructor for servlet class.
|
ServletHolder(String name,
Servlet servlet)
Constructor for servlet class.
|
Modifier and Type | Method and Description |
---|---|
void |
checkServletType()
Check to ensure class of servlet is acceptable.
|
int |
compareTo(ServletHolder sh)
Comparator by init order.
|
void |
destroyInstance(Object o) |
void |
doStart() |
void |
doStop() |
Servlet |
ensureInstance() |
boolean |
equals(Object o) |
String |
getContextPath() |
String |
getForcedPath() |
int |
getInitOrder() |
ServletRegistration.Dynamic |
getRegistration() |
Map<String,String> |
getRoleRefMap() |
String |
getRunAsRole() |
Servlet |
getServlet()
Get the servlet.
|
Servlet |
getServletInstance()
Get the servlet instance (no initialization done).
|
UnavailableException |
getUnavailableException() |
String |
getUserRoleLink(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 Servlet |
newInstance() |
protected void |
prepare(Request baseRequest,
ServletRequest request,
ServletResponse response)
Prepare to service a request.
|
void |
setEnabled(boolean enabled) |
void |
setForcedPath(String forcedPath) |
void |
setInitOrder(int order)
Set the initialize order.
|
void |
setRunAsRole(String role) |
void |
setServlet(Servlet servlet) |
void |
setUserRoleLink(String name,
String link)
Link a user role.
|
String |
toString() |
dump, 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
public static final String APACHE_SENTINEL_CLASS
public static final String JSP_GENERATED_PACKAGE_NAME
public ServletHolder()
public ServletHolder(BaseHolder.Source creator)
creator
- the holder sourcepublic ServletHolder(Servlet servlet)
servlet
- the servletpublic ServletHolder(String name, Class<? extends Servlet> servlet)
name
- the name of the servletservlet
- the servlet classpublic ServletHolder(String name, Servlet servlet)
name
- the servlet nameservlet
- the servletpublic 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 Comparable<ServletHolder>
public void setUserRoleLink(String name, String link)
name
- The role name as used by the servletlink
- The role name as used by the container.public String getUserRoleLink(String name)
name
- The name of the role@ManagedAttribute(value="forced servlet path", readonly=true) public String getForcedPath()
public void setForcedPath(String forcedPath)
forcedPath
- The forcedPath to set.public boolean isEnabled()
public void setEnabled(boolean enabled)
public void doStart() throws Exception
doStart
in class BaseHolder<Servlet>
Exception
public void initialize() throws Exception
BaseHolder
initialize
in class BaseHolder<Servlet>
Exception
- if unable to initializepublic void doStop() throws Exception
doStop
in class BaseHolder<Servlet>
Exception
public void destroyInstance(Object o) throws Exception
destroyInstance
in class Holder<Servlet>
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 Exception
Exception
- if unable to init the JSP Servletprotected void initMultiPart() throws Exception
Exception
- if unable to init the multipartpublic String getContextPath()
getContextPath
in interface UserIdentity.Scope
UserIdentity.Scope.getContextPath()
public Map<String,String> getRoleRefMap()
getRoleRefMap
in interface UserIdentity.Scope
UserIdentity.Scope.getRoleRefMap()
@ManagedAttribute(value="role to run servlet as", readonly=true) public String getRunAsRole()
public void setRunAsRole(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 availablepublic Servlet ensureInstance() throws ServletException, UnavailableException
ServletException
UnavailableException
public void handle(Request baseRequest, ServletRequest request, ServletResponse response) throws ServletException, UnavailableException, IOException
baseRequest
- the base requestrequest
- the requestresponse
- the responseServletException
- if unable to process the servletUnavailableException
- if servlet is unavailableIOException
- if unable to process the request or responsepublic ServletRegistration.Dynamic getRegistration()
protected Servlet newInstance() throws ServletException, IllegalAccessException, InstantiationException
ServletException
- if unable to create a new instanceIllegalAccessException
- if not allowed to create a new instanceInstantiationException
- if creating new instance resulted in errorCopyright © 1995-2016 Webtide. All Rights Reserved.