Top Description Inners Fields Constructors Methods
org.eclipse.jetty.ee10.webapp

public Class WebAppContext

extends ServletContextHandler
implements Context, Deployable
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.server.Deployable, org.eclipse.jetty.ee10.webapp.WebAppClassLoader.Context, org.eclipse.jetty.util.ClassVisibilityChecker
Annotations
@ManagedObject:Web Application ContextHandler
Imports
java.io.IOException, java.net.MalformedURLException, .URI, .URL, .URLClassLoader, java.nio.file.Path, java.security.PermissionCollection, java.util.ArrayList, .Arrays, .Collections, .EventListener, .HashMap, .HashSet, .List, .Map, .Set, java.util.stream.Collectors, jakarta.servlet.ServletRegistration.Dynamic, .ServletSecurityElement, jakarta.servlet.http.HttpSessionActivationListener, .HttpSessionAttributeListener, .HttpSessionBindingListener, .HttpSessionIdListener, .HttpSessionListener, org.eclipse.jetty.ee10.servlet.ErrorHandler, .ErrorPageErrorHandler, .ServletContextHandler, .ServletHandler, .SessionHandler, org.eclipse.jetty.ee10.servlet.security.ConstraintAware, .ConstraintMapping, .ConstraintSecurityHandler, org.eclipse.jetty.security.SecurityHandler, org.eclipse.jetty.server.Connector, .Deployable, .Server, org.eclipse.jetty.util.ExceptionUtil, .IO, .StringUtil, .URIUtil, org.eclipse.jetty.util.annotation.ManagedAttribute, .ManagedObject, org.eclipse.jetty.util.component.ClassLoaderDump, .DumpableCollection, org.eclipse.jetty.util.resource.Resource, .ResourceFactory, .Resources, org.slf4j.Logger, .LoggerFactory

Web Application Context Handler.

The WebAppContext handler is an extension of ContextHandler that coordinates the construction and configuration of nested handlers: ConstraintSecurityHandler, org.eclipse.jetty.ee10.servlet.SessionHandler and ServletHandler. The handlers are configured by pluggable configuration classes, with the default being WebXmlConfiguration and JettyWebXmlConfiguration.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class

Field Summary

Modifier and TypeField and Description
private static String[]
public static final ClassMatcher
public static final ClassMatcher
private boolean
private boolean
private Configurations
private String[]
private boolean
private boolean
private boolean
private String
private String
private boolean
private List<Resource>
private boolean
private ClassLoader
private boolean
private MetaData
private final List<String>
private boolean
private PermissionCollection
private Map<String, String>
private final ClassMatcher
private final ClassMatcher
private boolean
private Throwable
private String
pack-priv static final Logger
public static final String
public static final String
public static final String
Inherited from org.eclipse.jetty.ee10.servlet.ServletContextHandler:
__environment_contextStatus_jspConfig_objFactory_options_securityHandler_servletHandler_sessionHandlerDEFAULT_LISTENER_TYPE_INDEXDEFAULT_MAX_FORM_CONTENT_SIZEDEFAULT_MAX_FORM_KEYSEXTENDED_LISTENER_TYPE_INDEXMAX_FORM_CONTENT_SIZE_KEYMAX_FORM_KEYS_KEYNO_SECURITYNO_SESSIONSSECURITYSERVLET_LISTENER_TYPESSESSIONS

Constructor Summary

AccessConstructor and Description
public
public
WebAppContext(String
The URL or filename of the webapp directory or war file.
webApp
,
String
The context path
contextPath
)

public
WebAppContext(Resource
The URL or filename of the webapp directory or war file.
webApp
,
String
The context path
contextPath
)

public
WebAppContext(SessionHandler
SessionHandler for this web app
sessionHandler
,
SecurityHandler
SecurityHandler for this web app
securityHandler
,
ServletHandler
ServletHandler for this web app
servletHandler
,
ErrorHandler
ErrorHandler for this web app
errorHandler
)

public
WebAppContext(String
the context path
contextPath
,
SessionHandler
SessionHandler for this web app
sessionHandler
,
SecurityHandler
SecurityHandler for this web app
securityHandler
,
ServletHandler
ServletHandler for this web app
servletHandler
,
ErrorHandler
ErrorHandler for this web app
errorHandler
,
int options)

Method Summary

Modifier and TypeMethod and Description
private static void
addClasses(ClassMatcher matcher, String attribute, Server server, String... pattern)

public void
addConfiguration(Configuration... configuration)

public void
addOverrideDescriptor(String
The overrideDescriptor (file or URL) to add.
overrideDescriptor
)

The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml

public static void
addServerClasses(Server server, String... pattern)

public void
addServerClassMatcher(ClassMatcher
The class matcher of patterns to add to the server ClassMatcher
serverClasses
)

Add a ClassMatcher for server classes by combining with any existing matcher.

public static void
addSystemClasses(Server server, String... pattern)

public void
addSystemClassMatcher(ClassMatcher
The class matcher of patterns to add to the system ClassMatcher
systemClasses
)

Add a ClassMatcher for system classes by combining with any existing matcher.

public boolean
protected ClassLoader

Returns:

Either the configured loader, or a new ClassLoader that uses the loader.
configureClassLoader
(ClassLoader
The loader initially set on this context by setClassLoader(ClassLoader)
loader
)

Configure the context ClassLoader, potentially wrapping it.

protected void
public void
destroy()

Overrides org.eclipse.jetty.server.handler.ContextHandler.destroy.

Implements org.eclipse.jetty.util.component.Destroyable.destroy.

Destroys the managed Destroyable beans in the reverse order they were added.

protected void
doStart()

Overrides org.eclipse.jetty.ee10.servlet.ServletContextHandler.doStart.

Starts the managed lifecycle beans in the order they were added.

public void
dump(Appendable
The appendable to dump to
out
,
String
The indent to apply after any new lines.
indent
)

Overrides org.eclipse.jetty.ee10.servlet.ServletContextHandler.dump.

Implements org.eclipse.jetty.util.component.Dumpable.dump.

Dump this object (and children) into an Appendable using the provided indent after any new lines.

private void
public <T> T
getConfiguration(Class<? extends T> configClass)

public String[]
getConfigurationClasses()

Returns: Returns the configurations.

public Configurations
getConfigurations()

Returns: Returns the configurations.

public static WebAppContext
public String

Returns:

Returns the defaultsDescriptor.
getDefaultsDescriptor
()

The default descriptor is a web.xml format file that is applied to the context before the standard WEB-INF/web.xml

public String
getDescriptor()

Returns: the web.xml descriptor to use.

public List<Resource>
getExtraClasspath()

Implements org.eclipse.jetty.ee10.webapp.WebAppClassLoader.Context.getExtraClasspath.

Returns: Comma or semicolon separated path of filenames or URLs pointing to directories or jar files.

public MetaData
public String

Returns:

Returns the Override Descriptor.
getOverrideDescriptor
()

The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml

public List<String>

Returns:

Returns the Override Descriptor list
getOverrideDescriptors
()

An override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml

public PermissionCollection
public Resource
getResource(String
the path within the base resource to attempt to get
pathInContext
)

Overrides org.eclipse.jetty.ee10.servlet.ServletContextHandler.getResource.

Attempt to get a Resource from the Context.

public String
public Map<String, String>
public ResourceFactory
public String[]
public ClassMatcher
getServerClassMatcher()

Returns: The ClassMatcher used to match Server (hidden) classes

public String[]
public ClassMatcher
getSystemClassMatcher()

Returns: The ClassMatcher used to match System (protected) classes

public Throwable

Returns:

A throwable if the webapp is unavailable or null
getUnavailableException
()

Get an exception that caused the webapp to be unavailable

public String
getWar()

Returns: Returns the war as a file or URL string (Resource).

public Resource
public void
public boolean
public boolean

Returns:

true if configuration discovery.
isConfigurationDiscovered
()

Is the context Automatically configured.

public boolean
public boolean
isCopyWebDir()

Returns: True if the webdir is copied (to allow hot replacement of jars on windows)

public boolean
isCopyWebInf()

Returns: True if the web-inf lib and classes directories are copied (to allow hot replacement of jars on windows)

public boolean
isDistributable()

Returns: Returns the distributable.

public boolean
isExtractWAR()

Returns: Returns the extractWAR.

public boolean
public boolean
isParentLoaderPriority()

Implements org.eclipse.jetty.ee10.webapp.WebAppClassLoader.Context.isParentLoaderPriority.

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

public boolean
isServerClass(Class<?>
The fully qualified name of the class.
clazz
)

Implements org.eclipse.jetty.util.ClassVisibilityChecker.isServerClass.

Is the class a Server Class.

public boolean
public boolean
isSystemClass(Class<?>
The fully qualified name of the class.
clazz
)

Implements org.eclipse.jetty.util.ClassVisibilityChecker.isSystemClass.

Is the class a System Class.

public boolean
public boolean
protected void
protected Configurations
public ServletContextHandler.ServletContextApi
public void
public void
preConfigure()

Pre configure the web application.

public void
public void
removeConfiguration(Class<? extends Configuration>... configurations)

public boolean
public String
public void
setAllowDuplicateFragmentNames(boolean allowDuplicateFragmentNames)

public void
public void
setConfigurationClasses(String[]
The configuration class names. If setConfigurations is not called these classes are used to create a configurations array.
configurations
)

public void
public void
setConfigurationDiscovered(boolean
true if configuration discovery is enabled for automatic configuration from the context
discovered
)

Set the configuration discovery mode.

public void
setConfigurations(Configurations
The configurations to set.
configurations
)

public void
setConfigurations(Configuration[]
The configurations to set.
configurations
)

public void
public void
setContextWhiteList(String...
the whitelist of contexts
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.

public void
setCopyWebDir(boolean
True if the webdir is copied (to allow hot replacement of jars)
copy
)

public void
setCopyWebInf(boolean
True if the web-inf lib and classes directories are copied (to allow hot replacement of jars on windows)
copyWebInf
)

public void
public void
setDefaultsDescriptor(String
The defaultsDescriptor to set.
defaultsDescriptor
)

The default descriptor is a web.xml format file that is applied to the context before the standard WEB-INF/web.xml

public void
setDescriptor(String
the web.xml descriptor to use. If set to null, WEB-INF/web.xml is used if it exists.
descriptor
)

Set the web.xml descriptor to use.

public void
setDisplayName(String
The servletContextName to set.
servletContextName
)

Overrides org.eclipse.jetty.server.handler.ContextHandler.setDisplayName.

public void
setDistributable(boolean
The distributable to set.
distributable
)

public void
setExtraClasspath(String
Comma or semicolon separated path of filenames or URLs pointing to directories or jar files. Directories should end with '/'.
extraClasspath
)

Set the Extra ClassPath via delimited String.

public void
setExtraClasspath(List<Resource> extraClasspath)

public void
setExtractWAR(boolean
True if war files are extracted
extractWAR
)

public void
setLogUrlOnStart(boolean
whether or not the log message is created
logOnStart
)

Sets whether or not the web app name and URL is logged on startup

public void
setOverrideDescriptor(String
The overrideDescritpor to set.
overrideDescriptor
)

The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml

public void
setOverrideDescriptors(List<String>
The overrideDescriptors (file or URL) to set.
overrideDescriptors
)

The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml

public void
setParentLoaderPriority(boolean
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.parentLoaderPriority
java2compliant
)

public void
setPermissions(PermissionCollection
The permissions to set.
permissions
)

public void
setResourceAlias(String
the alias for a resource
alias
,
String
the uri for the resource
uri
)

Set Resource Alias.

public void
public void
setServer(Server
the Server to associate to this Handler
server
)

Overrides org.eclipse.jetty.server.handler.ContextHandler.setServer.

Implements org.eclipse.jetty.server.Handler.setServer.

Set the Server to associate to this Handler.

public void
setServerClassMatcher(ClassMatcher
the server classes pattern
serverClasses
)

Set the server classes patterns.

public Set<String>
setServletSecurity(ServletRegistration.Dynamic
ServletRegistration.Dynamic instance that setServletSecurity was called on
registration
,
ServletSecurityElement
new security info
servletSecurityElement
)

Overrides org.eclipse.jetty.ee10.servlet.ServletContextHandler.setServletSecurity.

Delegate for ServletRegistration.Dynamic.setServletSecurity method

public void
setSystemClassMatcher(ClassMatcher
the system classes pattern
systemClasses
)

Set the system classes patterns.

public void
setThrowUnavailableOnStartupException(boolean throwIfStartupException)

public void
setWar(String
The war to set as a file name or URL.
war
)

Set the war of the webapp.

public void
setWarResource(Resource
The war to set as a Resource.
war
)

Set the war of the webapp as a Resource.

protected void
startContext()

Overrides org.eclipse.jetty.ee10.servlet.ServletContextHandler.startContext.

Finish constructing handlers and link them together.

protected void
public String
toString()

Overrides org.eclipse.jetty.server.handler.ContextHandler.toString.

Returns a string representation of the object.

Inherited from org.eclipse.jetty.ee10.servlet.ServletContextHandler:
addEventListeneraddFilteraddFilteraddFilteraddFilteraddLocaleEncodingaddProgrammaticListeneraddRolesaddServletaddServletaddServletaddServletaddServletContainerInitializeraddServletContainerInitializeraddServletContainerInitializercallContextDestroyedcallContextInitializedcontextDestroyedcontextInitializeddoStopdynamicHolderAddedgetContextgetContextPathEncodedgetCurrentServletContextgetCurrentServletContextHandlergetDefaultRequestCharacterEncodinggetDefaultResponseCharacterEncodinggetDefaultSecurityHandlerClassgetInitParametergetInitParameterNamesgetInitParamsgetInvocationTypegetLocaleEncodinggetLocaleEncodinggetLocaleEncodingsgetLoggergetMaxFormContentSizegetMaxFormKeysgetObjectFactorygetRequestContextPathgetResourcePathsgetSecurityHandlergetServletContextgetServletContextgetServletContextHandlergetServletContextHandlergetServletHandlergetSessionHandlergetWelcomeFileshandleByContextHandlerinsertHandlerisDurableListenerisProgrammaticListenerisUsingSecurityManagerloadClassnewContextnewResourcenewResourcenewResourcenewSecurityHandlernewServletContextRequestnewServletHandlernewSessionHandlernotifyEnterScopenotifyExitScoperequestDestroyedrequestInitializedsetDefaultRequestCharacterEncodingsetDefaultResponseCharacterEncodingsetDefaultSecurityHandlerClasssetHandlersetInitParametersetLoggersetMaxFormContentSizesetMaxFormKeyssetSecurityHandlersetServletHandlersetSessionHandlersetTempDirectorysetUsingSecurityManagersetWelcomeFileswrapRequestwrapResponse