@ManagedObject(value="Web Application ContextHandler") public class WebAppContext extends ServletContextHandler implements WebAppClassLoader.Context
ConstraintSecurityHandler
, SessionHandler
and ServletHandler
.
The handlers are configured by pluggable configuration classes, with
the default being WebXmlConfiguration
and
JettyWebXmlConfiguration
.Modifier and Type | Class and Description |
---|---|
class |
WebAppContext.Context |
ServletContextHandler.Decorator, ServletContextHandler.JspConfig, ServletContextHandler.JspPropertyGroup, ServletContextHandler.ServletContainerInitializerCaller, ServletContextHandler.TagLib
ContextHandler.AliasCheck, ContextHandler.ApproveAliases, ContextHandler.ApproveNonExistentDirectoryAliases, ContextHandler.ApprovePathPrefixAliases, ContextHandler.ApproveSameSuffixAliases, ContextHandler.Availability, ContextHandler.NoContext
AbstractLifeCycle.AbstractLifeCycleListener
LifeCycle.Listener
Container.InheritedListener, Container.Listener
Modifier and Type | Field and Description |
---|---|
static String[] |
__dftServerClasses |
static String[] |
__dftSystemClasses |
static String |
BASETEMPDIR |
static String[] |
DEFAULT_CONFIGURATION_CLASSES |
static String |
ERROR_PAGE |
static String |
SERVER_SRV_CLASSES |
static String |
SERVER_SYS_CLASSES |
static String |
TEMPDIR |
static String |
WEB_DEFAULTS_XML |
_decorators, _defaultSecurityHandlerClass, _jspConfig, _options, _securityHandler, _servletHandler, _sessionHandler, NO_SECURITY, NO_SESSIONS, SECURITY, SESSIONS
_scontext, DEFAULT_LISTENER_TYPE_INDEX, EXTENDED_LISTENER_TYPE_INDEX, MANAGED_ATTRIBUTES, SERVLET_LISTENER_TYPES, SERVLET_MAJOR_VERSION, SERVLET_MINOR_VERSION
_nextScope, _outerScope
_handler
Constructor and Description |
---|
WebAppContext() |
WebAppContext(HandlerContainer parent,
String contextPath,
SessionHandler sessionHandler,
SecurityHandler securityHandler,
ServletHandler servletHandler,
ErrorHandler errorHandler,
int options)
This constructor is used in the geronimo integration.
|
WebAppContext(HandlerContainer parent,
String webApp,
String contextPath) |
WebAppContext(SessionHandler sessionHandler,
SecurityHandler securityHandler,
ServletHandler servletHandler,
ErrorHandler errorHandler)
This constructor is used in the geronimo integration.
|
WebAppContext(String webApp,
String contextPath) |
Modifier and Type | Method and Description |
---|---|
void |
addEventListener(EventListener listener)
Add EventListener
Convenience method that calls
setEventListeners(EventListener[]) |
void |
addOverrideDescriptor(String overrideDescriptor)
The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml
|
void |
addServerClass(String classOrPackage)
Add to the list of Server classes.
|
void |
addSystemClass(String classOrPackage)
Add to the list of System classes.
|
void |
configure() |
void |
destroy()
Destroys the managed Destroyable beans in the reverse order they were added.
|
protected void |
doStart()
Starts the managed lifecycle beans in the order they were added.
|
protected void |
doStop()
Stops the managed lifecycle beans in the reverse order they were added.
|
String[] |
getConfigurationClasses() |
Configuration[] |
getConfigurations() |
static WebAppContext |
getCurrentWebAppContext() |
static String[] |
getDefaultConfigurationClasses() |
String |
getDefaultsDescriptor()
The default descriptor is a web.xml format file that is applied to the context before the standard WEB-INF/web.xml
|
String[] |
getDefaultServerClasses() |
String[] |
getDefaultSystemClasses() |
String |
getDescriptor() |
String |
getExtraClasspath() |
MetaData |
getMetaData() |
String |
getOverrideDescriptor()
The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml
|
List<String> |
getOverrideDescriptors()
An override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml
|
PermissionCollection |
getPermissions() |
Resource |
getResource(String uriInContext) |
String |
getResourceAlias(String path) |
Map<String,String> |
getResourceAliases() |
String[] |
getServerClasses() |
String[] |
getSystemClasses() |
File |
getTempDirectory() |
Throwable |
getUnavailableException()
Get an exception that caused the webapp to be unavailable
|
String |
getWar() |
Resource |
getWebInf() |
boolean |
isAllowDuplicateFragmentNames() |
boolean |
isConfigurationDiscovered()
Is the context Automatically configured.
|
boolean |
isCopyWebDir() |
boolean |
isCopyWebInf() |
boolean |
isDistributable() |
boolean |
isExtractWAR() |
boolean |
isLogUrlOnStart() |
boolean |
isParentLoaderPriority() |
boolean |
isPersistTempDirectory() |
boolean |
isServerClass(String name)
Is the class a Server Class.
|
boolean |
isSystemClass(String name)
Is the class a System Class.
|
boolean |
isThrowUnavailableOnStartupException() |
protected void |
loadConfigurations() |
protected void |
loadSystemClasses() |
void |
postConfigure() |
void |
preConfigure()
Pre configure the web application.
|
void |
prependServerClass(String classOrPackage)
Prepend to the list of Server classes.
|
void |
prependSystemClass(String classOrPackage)
Prepend to the list of System classes.
|
void |
removeEventListener(EventListener listener)
Remove a context event listeners.
|
String |
removeResourceAlias(String alias) |
void |
setAllowDuplicateFragmentNames(boolean allowDuplicateFragmentNames) |
void |
setClassLoader(ClassLoader classLoader) |
void |
setConfigurationClasses(List<String> configurations) |
void |
setConfigurationClasses(String[] configurations) |
void |
setConfigurationDiscovered(boolean discovered)
Set the configuration discovery mode.
|
void |
setConfigurations(Configuration[] configurations) |
void |
setContextWhiteList(String[] contextWhiteList)
Set the context white list
In certain circumstances you want may want to deny access of one webapp from another
when you may not fully trust the webapp.
|
void |
setCopyWebDir(boolean copy) |
void |
setCopyWebInf(boolean copyWebInf) |
void |
setDefaultsDescriptor(String defaultsDescriptor)
The default descriptor is a web.xml format file that is applied to the context before the standard WEB-INF/web.xml
|
void |
setDescriptor(String descriptor) |
void |
setDisplayName(String servletContextName) |
void |
setDistributable(boolean distributable) |
void |
setEventListeners(EventListener[] eventListeners)
Set the context event listeners.
|
void |
setExtraClasspath(String extraClasspath) |
void |
setExtractWAR(boolean extractWAR) |
void |
setLogUrlOnStart(boolean logOnStart)
Sets whether or not the web app name and URL is logged on startup
|
void |
setOverrideDescriptor(String overrideDescriptor)
The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml
|
void |
setOverrideDescriptors(List<String> overrideDescriptors)
The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml
|
void |
setParentLoaderPriority(boolean java2compliant) |
void |
setPermissions(PermissionCollection permissions) |
void |
setPersistTempDirectory(boolean persist)
If true the temp directory for this
webapp will be kept when the webapp stops.
|
void |
setResourceAlias(String alias,
String uri)
Set Resource Alias.
|
void |
setResourceAliases(Map<String,String> map) |
void |
setServer(Server server) |
void |
setServerClasses(String[] serverClasses)
Set the server classes patterns.
|
Set<String> |
setServletSecurity(ServletRegistration.Dynamic registration,
ServletSecurityElement servletSecurityElement)
Delegate for ServletRegistration.Dynamic.setServletSecurity method
|
void |
setSystemClasses(String[] systemClasses)
Set the system classes patterns.
|
void |
setTempDirectory(File dir)
Set temporary directory for context.
|
void |
setThrowUnavailableOnStartupException(boolean throwIfStartupException) |
void |
setWar(String war) |
protected void |
startContext()
Finish constructing handlers and link them together.
|
protected void |
startWebapp() |
String |
toString() |
addDecorator, addFilter, addFilter, addFilter, addRoles, addServlet, addServlet, addServlet, callContextDestroyed, callContextInitialized, dynamicHolderAdded, getDecorators, getDefaultSecurityHandlerClass, getSecurityHandler, getServletHandler, getSessionHandler, insertHandler, newSecurityHandler, newServletHandler, newSessionHandler, setDecorators, setDefaultSecurityHandlerClass, setHandler, setSecurityHandler, setServletHandler, setSessionHandler
addAliasCheck, addLocaleEncoding, addProgrammaticListener, addVirtualHosts, checkAlias, checkContext, checkContextPath, checkManagedAttribute, checkVirtualHost, clearAttributes, doHandle, doScope, dump, getAliasChecks, getAllowNullPathInfo, getAttribute, getAttributeNames, getAttributes, getBaseResource, getClassLoader, getClassPath, getContextHandler, getContextPath, getCurrentContext, getDisplayName, getErrorHandler, getEventListeners, getInitParameter, getInitParameterNames, getInitParams, getLocaleEncoding, getLocaleEncoding, getLocaleEncodings, getLogger, getMaxFormContentSize, getMaxFormKeys, getMimeTypes, getProtectedTargets, getResourceBase, getResourcePaths, getServletContext, getVirtualHosts, getWelcomeFiles, handle, isAvailable, isCompactPath, isProgrammaticListener, isProtectedTarget, isShutdown, loadClass, newResource, newResource, newResource, removeAttribute, removeVirtualHosts, setAliasChecks, setAllowNullPathInfo, setAttribute, setAttributes, setAvailable, setBaseResource, setCompactPath, setContextPath, setErrorHandler, setInitParameter, setLogger, setManagedAttribute, setMaxFormContentSize, setMaxFormKeys, setMimeTypes, setProtectedTargets, setResourceBase, setVirtualHosts, setWelcomeFiles, shutdown
handle, never, nextHandle, nextScope
expandChildren, getHandler, getHandlers
expandHandler, findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass
dumpThis, getServer
addBean, addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBeans
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
newResource
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
public static final String TEMPDIR
public static final String BASETEMPDIR
public static final String WEB_DEFAULTS_XML
public static final String ERROR_PAGE
public static final String SERVER_SYS_CLASSES
public static final String SERVER_SRV_CLASSES
public static final String[] DEFAULT_CONFIGURATION_CLASSES
public static final String[] __dftSystemClasses
public static final String[] __dftServerClasses
public WebAppContext()
public WebAppContext(String webApp, String contextPath)
contextPath
- The context pathwebApp
- The URL or filename of the webapp directory or war file.public WebAppContext(HandlerContainer parent, String webApp, String contextPath)
parent
- The parent HandlerContainer.contextPath
- The context pathwebApp
- The URL or filename of the webapp directory or war file.public WebAppContext(SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler)
sessionHandler
- SessionHandler for this web appsecurityHandler
- SecurityHandler for this web appservletHandler
- ServletHandler for this web apperrorHandler
- ErrorHandler for this web apppublic WebAppContext(HandlerContainer parent, String contextPath, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler, int options)
sessionHandler
- SessionHandler for this web appsecurityHandler
- SecurityHandler for this web appservletHandler
- ServletHandler for this web apperrorHandler
- ErrorHandler for this web apppublic static WebAppContext getCurrentWebAppContext()
public void setDisplayName(String servletContextName)
setDisplayName
in class ContextHandler
servletContextName
- The servletContextName to set.public Throwable getUnavailableException()
public void setResourceAlias(String alias, String uri)
alias
- uri
- public void setClassLoader(ClassLoader classLoader)
setClassLoader
in class ContextHandler
classLoader
- The classLoader to set.public Resource getResource(String uriInContext) throws MalformedURLException
getResource
in class ContextHandler
MalformedURLException
public boolean isConfigurationDiscovered()
public void setConfigurationDiscovered(boolean discovered)
discovered
- true if configuration discovery is enabled for automatic configuration from the contextpublic void preConfigure() throws Exception
The method is normally called from AbstractLifeCycle.start()
. It performs
the discovery of the configurations to be applied to this context,
specifically:
Configuration
instances with a call to loadConfigurations()
.
loadSystemClasses()
loadServerClasses()
Configuration.preConfigure(WebAppContext)
method of all
Configuration instances.
Exception
protected void doStart() throws Exception
ContainerLifeCycle
doStart
in class ContextHandler
Exception
AbstractHandler.doStart()
protected void doStop() throws Exception
ContainerLifeCycle
doStop
in class ServletContextHandler
Exception
ContextHandler.doStop()
public void destroy()
ContainerLifeCycle
destroy
in interface Handler
destroy
in interface Destroyable
destroy
in class HandlerWrapper
@ManagedAttribute(value="configuration classes used to configure webapp", readonly=true) public String[] getConfigurationClasses()
public Configuration[] getConfigurations()
@ManagedAttribute(value="default web.xml deascriptor applied before standard web.xml", readonly=true) public String getDefaultsDescriptor()
public String getOverrideDescriptor()
@ManagedAttribute(value="web.xml deascriptors applied after standard web.xml", readonly=true) public List<String> getOverrideDescriptors()
public PermissionCollection getPermissions()
getPermissions
in interface WebAppClassLoader.Context
@ManagedAttribute(value="classes and packages hidden by the context classloader", readonly=true) public String[] getServerClasses()
setServerClasses(String[])
public void addServerClass(String classOrPackage)
classOrPackage
- A fully qualified class name (eg com.foo.MyClass)
or a qualified package name ending with '.' (eg com.foo.). If the class
or package has '-' it is excluded from the server classes and order is thus
important when added system class patterns. This argument may also be a comma
separated list of classOrPackage patterns.setServerClasses(String[])
,
Jetty Documentation: Classloadingpublic void prependServerClass(String classOrPackage)
classOrPackage
- A fully qualified class name (eg com.foo.MyClass)
or a qualified package name ending with '.' (eg com.foo.). If the class
or package has '-' it is excluded from the server classes and order is thus
important when added system class patterns. This argument may also be a comma
separated list of classOrPackage patterns.setServerClasses(String[])
,
Jetty Documentation: Classloading@ManagedAttribute(value="classes and packages given priority by context classloader", readonly=true) public String[] getSystemClasses()
setSystemClasses(String[])
public void addSystemClass(String classOrPackage)
classOrPackage
- A fully qualified class name (eg com.foo.MyClass)
or a qualified package name ending with '.' (eg com.foo.). If the class
or package has '-' it is excluded from the system classes and order is thus
important when added system class patterns. This argument may also be a comma
separated list of classOrPackage patterns.setSystemClasses(String[])
,
Jetty Documentation: Classloadingpublic void prependSystemClass(String classOrPackage)
classOrPackage
- A fully qualified class name (eg com.foo.MyClass)
or a qualified package name ending with '.' (eg com.foo.). If the class
or package has '-' it is excluded from the system classes and order is thus
important when added system class patterns.This argument may also be a comma
separated list of classOrPackage patterns.setSystemClasses(String[])
,
Jetty Documentation: Classloadingpublic boolean isServerClass(String name)
WebAppClassLoader.Context
isServerClass
in interface WebAppClassLoader.Context
name
- The fully qualified name of the class.public boolean isSystemClass(String name)
WebAppClassLoader.Context
isSystemClass
in interface WebAppClassLoader.Context
name
- The fully qualified name of the class.protected void loadSystemClasses()
@ManagedAttribute(value="war file location", readonly=true) public String getWar()
public Resource getWebInf() throws IOException
IOException
@ManagedAttribute(value="web application distributable") public boolean isDistributable()
@ManagedAttribute(value="extract war", readonly=true) public boolean isExtractWAR()
@ManagedAttribute(value="webdir copied on deploy (allows hot replacement on windows)", readonly=true) public boolean isCopyWebDir()
public boolean isCopyWebInf()
@ManagedAttribute(value="parent classloader given priority", readonly=true) public boolean isParentLoaderPriority()
isParentLoaderPriority
in interface WebAppClassLoader.Context
public static String[] getDefaultConfigurationClasses()
public String[] getDefaultServerClasses()
public String[] getDefaultSystemClasses()
public String toString()
toString
in class ContextHandler
public void setConfigurationClasses(String[] configurations)
configurations
- The configuration class names. If setConfigurations is not called
these classes are used to create a configurations array.public void setConfigurations(Configuration[] configurations)
configurations
- The configurations to set.public void setDefaultsDescriptor(String defaultsDescriptor)
defaultsDescriptor
- The defaultsDescriptor to set.public void setOverrideDescriptor(String overrideDescriptor)
overrideDescriptor
- The overrideDescritpor to set.public void setOverrideDescriptors(List<String> overrideDescriptors)
overrideDescriptors
- The overrideDescriptors (file or URL) to set.public void addOverrideDescriptor(String overrideDescriptor)
overrideDescriptor
- The overrideDescriptor (file or URL) to add.@ManagedAttribute(value="standard web.xml descriptor", readonly=true) public String getDescriptor()
public void setDescriptor(String descriptor)
descriptor
- the web.xml descriptor to use. If set to null, WEB-INF/web.xml is used if it exists.public void setDistributable(boolean distributable)
distributable
- The distributable to set.public void setEventListeners(EventListener[] eventListeners)
ContextHandler
setEventListeners
in class ContextHandler
eventListeners
- the event listenersServletContextListener
,
ServletContextAttributeListener
,
ServletRequestListener
,
ServletRequestAttributeListener
public void addEventListener(EventListener listener)
setEventListeners(EventListener[])
addEventListener
in class ContextHandler
listener
- ServletContextListener
,
ServletContextAttributeListener
,
ServletRequestListener
,
ServletRequestAttributeListener
public void removeEventListener(EventListener listener)
ContextHandler
removeEventListener
in class ContextHandler
ServletContextListener
,
ServletContextAttributeListener
,
ServletRequestListener
,
ServletRequestAttributeListener
public void setExtractWAR(boolean extractWAR)
extractWAR
- True if war files are extractedpublic void setCopyWebDir(boolean copy)
copy
- True if the webdir is copied (to allow hot replacement of jars)public void setCopyWebInf(boolean copyWebInf)
copyWebInf
- True if the web-inf lib and classes directories are copied (to allow hot replacement of jars on windows)public void setParentLoaderPriority(boolean java2compliant)
java2compliant
- True if the classloader should delegate first to the parent
classloader (standard java behaviour) or false if the classloader
should first try to load from WEB-INF/lib or WEB-INF/classes (servlet
spec recommendation). Default is false or can be set by the system
property org.eclipse.jetty.server.webapp.parentLoaderPrioritypublic void setPermissions(PermissionCollection permissions)
permissions
- The permissions to set.public void setContextWhiteList(String[] contextWhiteList)
contextWhiteList
- public void setServerClasses(String[] serverClasses)
Server classes/packages are classes used to implement the server and are hidden from the context. If the context needs to load these classes, it must have its own copy of them in WEB-INF/lib or WEB-INF/classes. A class pattern is a string of one of the forms:
serverClasses
- The serverClasses to set.public void setSystemClasses(String[] systemClasses)
System classes/packages are classes provided by the JVM and that
cannot be replaced by classes of the same name from WEB-INF,
regardless of the value of setParentLoaderPriority(boolean)
.
A class pattern is a string of one of the forms:
systemClasses
- The systemClasses to set.public void setTempDirectory(File dir)
dir
- Writable temporary directory.@ManagedAttribute(value="temporary directory location", readonly=true) public File getTempDirectory()
public void setPersistTempDirectory(boolean persist)
delete
- public boolean isPersistTempDirectory()
public void setWar(String war)
war
- The war to set as a file name or URL@ManagedAttribute(value="extra classpath for context classloader", readonly=true) public String getExtraClasspath()
getExtraClasspath
in interface WebAppClassLoader.Context
public void setExtraClasspath(String extraClasspath)
extraClasspath
- Comma or semicolon separated path of filenames or URLs
pointing to directories or jar files. Directories should end
with '/'.public boolean isLogUrlOnStart()
public void setLogUrlOnStart(boolean logOnStart)
logOnStart
- whether or not the log message is createdpublic void setServer(Server server)
setServer
in interface Handler
setServer
in class ContextHandler
public boolean isAllowDuplicateFragmentNames()
public void setAllowDuplicateFragmentNames(boolean allowDuplicateFragmentNames)
public void setThrowUnavailableOnStartupException(boolean throwIfStartupException)
public boolean isThrowUnavailableOnStartupException()
protected void startContext() throws Exception
ServletContextHandler
startContext
in class ServletContextHandler
Exception
ContextHandler.startContext()
public Set<String> setServletSecurity(ServletRegistration.Dynamic registration, ServletSecurityElement servletSecurityElement)
ServletContextHandler
setServletSecurity
in class ServletContextHandler
registration
- ServletRegistration.Dynamic instance that setServletSecurity was called onservletSecurityElement
- new security infopublic MetaData getMetaData()
Copyright © 1995-2015 Webtide. All Rights Reserved.