Class WebAppContext
- All Implemented Interfaces:
WebAppClassLoader.Context
,AliasCheck
,Deployable
,Handler
,Handler.Container
,Handler.Singleton
,Request.Handler
,Attributes
,ClassVisibilityChecker
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,LifeCycle
,Invocable
The WebAppContext handler is an extension of ContextHandler that
coordinates the construction and configuration of nested handlers:
ConstraintSecurityHandler
, SessionHandler
and ServletHandler
.
The handlers are configured by pluggable configuration classes, with
the default being WebXmlConfiguration
and
JettyWebXmlConfiguration
.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.ee10.servlet.ServletContextHandler
ServletContextHandler.ContextStatus, ServletContextHandler.JspConfig, ServletContextHandler.JspPropertyGroup, ServletContextHandler.ServletContainerInitializerCaller, ServletContextHandler.ServletContainerInitializerStarter, ServletContextHandler.ServletContextApi, ServletContextHandler.ServletContextScopeListener, ServletContextHandler.ServletRequestInfo, ServletContextHandler.ServletResponseInfo, ServletContextHandler.ServletScopedContext, ServletContextHandler.TagLib
Nested classes/interfaces inherited from class org.eclipse.jetty.server.handler.ContextHandler
ContextHandler.Availability, ContextHandler.ContextScopeListener, ContextHandler.ScopedContext
Nested classes/interfaces inherited from class org.eclipse.jetty.server.Handler.Abstract
Handler.Abstract.NonBlocking
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopException
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.Attributes
Attributes.Layer, Attributes.Lazy, Attributes.Mapped, Attributes.Synthetic, Attributes.Wrapper
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
Nested classes/interfaces inherited from interface org.eclipse.jetty.server.Handler
Handler.Abstract, Handler.AbstractContainer, Handler.Collection, Handler.Container, Handler.Sequence, Handler.Singleton, Handler.Wrapper
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.Task
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.server.Request.Handler
Request.Handler.AbortException
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ClassMatcher
Deprecated, for removal: This API element is subject to removal in a future version.static final ClassMatcher
Deprecated, for removal: This API element is subject to removal in a future version.static final String
Deprecated, for removal: This API element is subject to removal in a future version.useWebAppClassLoading.HIDDEN_CLASSES_ATTRIBUTE
instead.static final String
Deprecated, for removal: This API element is subject to removal in a future version.useWebAppClassLoading.PROTECTED_CLASSES_ATTRIBUTE
instead.static final String
Fields inherited from class org.eclipse.jetty.ee10.servlet.ServletContextHandler
__environment, _contextStatus, _jspConfig, _objFactory, _options, _securityHandler, _servletHandler, _sessionHandler, DEFAULT_LISTENER_TYPE_INDEX, DEFAULT_MAX_FORM_CONTENT_SIZE, DEFAULT_MAX_FORM_KEYS, ENVIRONMENT, EXTENDED_LISTENER_TYPE_INDEX, MAX_FORM_CONTENT_SIZE_KEY, MAX_FORM_KEYS_KEY, NO_SECURITY, NO_SESSIONS, SECURITY, SERVLET_LISTENER_TYPES, SESSIONS
Fields inherited from class org.eclipse.jetty.server.handler.ContextHandler
CROSS_CONTEXT_ATTRIBUTE, MANAGED_ATTRIBUTES
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, STARTED, STARTING, STOPPED, STOPPING
Fields inherited from interface org.eclipse.jetty.util.Attributes
NULL
Fields inherited from interface org.eclipse.jetty.server.Deployable
ATTRIBUTE_PREFIX, CONFIGURATION_CLASSES, CONTAINER_SCAN_JARS, CONTEXT_HANDLER_CLASS, CONTEXT_PATH, DEFAULTS_DESCRIPTOR, EE_ENVIRONMENT_NAME_PATTERN, ENVIRONMENT, ENVIRONMENT_COMPARATOR, ENVIRONMENT_XML, EXTRACT_WARS, PARENT_LOADER_PRIORITY, SCI_EXCLUSION_PATTERN, SCI_ORDER, TEMP_DIR, WAR, WEBINF_SCAN_JARS
Fields inherited from interface org.eclipse.jetty.util.thread.Invocable
__nonBlocking, NOOP
-
Constructor Summary
ConstructorDescriptionWebAppContext
(String webApp, String contextPath) WebAppContext
(String contextPath, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler, int options) WebAppContext
(SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler) WebAppContext
(Resource webApp, String contextPath) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConfiguration
(Configuration... configuration) void
addHiddenClassMatcher
(ClassMatcher hiddenClasses) Add a ClassMatcher for hidden (server) classes by combining with any existing matcher.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.xmlvoid
addProtectedClassMatcher
(ClassMatcher protectedClasses) Add a ClassMatcher for protected (system) classes by combining with any existing matcher.static void
addServerClasses
(Server server, String... patterns) Deprecated, for removal: This API element is subject to removal in a future version.void
addServerClassMatcher
(ClassMatcher serverClasses) Deprecated, for removal: This API element is subject to removal in a future version.static void
addSystemClasses
(Server server, String... patterns) Deprecated, for removal: This API element is subject to removal in a future version.void
addSystemClassMatcher
(ClassMatcher systemClasses) Deprecated, for removal: This API element is subject to removal in a future version.protected void
Prevent the temp directory from being deleted during the normal stop sequence, and require thatContextHandler.cleanupAfterStop()
is explicitly called after the webapp classloader is closedboolean
protected ClassLoader
configureClassLoader
(ClassLoader loader) Configure the contextClassLoader
, potentially wrapping it.protected void
Create the temporary directory.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.void
dump
(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.protected String
Create a canonical name for a context temp directory.<T> T
getConfiguration
(Class<? extends T> configClass) String[]
static WebAppContext
The default descriptor is a web.xml format file that is applied to the context before the standard WEB-INF/web.xmlString[]
The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xmlAn override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xmlString[]
getResource
(String pathInContext) Attempt to get a Resource from the Context.getResourceAlias
(String path) protected Resource
If the webapp has no baseresource yet, use the war to make the temp directory name.String[]
Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.String[]
Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Get an exception that caused the webapp to be unavailablegetWar()
void
initializeDefaults
(Map<String, String> properties) boolean
boolean
Is the context Automatically configured.boolean
boolean
boolean
boolean
boolean
boolean
isHiddenClass
(Class<?> clazz) Is the class a Hidden (Server) Class.boolean
isHiddenResource
(String name, URL url) boolean
boolean
boolean
isProtectedClass
(Class<?> clazz) Is the class a Protected (System) Class.boolean
isProtectedResource
(String name, URL url) boolean
isServerClass
(Class<?> clazz) Deprecated, for removal: This API element is subject to removal in a future version.boolean
isSystemClass
(Class<?> clazz) Deprecated, for removal: This API element is subject to removal in a future version.boolean
protected void
protected void
Generate a reasonable name for the temp directory because one has not been explicitly configured by the user withContextHandler.setTempDirectory(File)
.protected Configurations
void
void
Pre configure the web application.void
removeConfiguration
(Class<? extends Configuration>... configurations) void
removeConfiguration
(Configuration... configurations) boolean
removeEventListener
(EventListener listener) Remove an event listener.removeResourceAlias
(String alias) void
setAllowDuplicateFragmentNames
(boolean allowDuplicateFragmentNames) void
setClassLoader
(ClassLoader classLoader) void
setConfigurationClasses
(String[] configurations) void
setConfigurationClasses
(List<String> configurations) void
setConfigurationDiscovered
(boolean discovered) Set the configuration discovery mode.void
setConfigurations
(Configuration[] configurations) void
setConfigurations
(Configurations configurations) void
setContextPath
(String contextPath) 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
setDefaultContextPath
(String contextPath) 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.xmlvoid
setDescriptor
(String descriptor) Set the web.xml descriptor to use.void
setDisplayName
(String servletContextName) void
setDistributable
(boolean distributable) void
setExtraClasspath
(String extraClasspath) Set the Extra ClassPath via delimited String.void
setExtraClasspath
(List<Resource> extraClasspath) void
setExtractWAR
(boolean extractWAR) void
setHiddenClassMatcher
(ClassMatcher hiddenClasses) Set the hidden (server) classes patterns.void
setLogUrlOnStart
(boolean logOnStart) Sets whether or not the web app name and URL is logged on startupvoid
setOverrideDescriptor
(String overrideDescriptor) The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xmlvoid
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.xmlvoid
setParentLoaderPriority
(boolean java2compliant) void
setPermissions
(PermissionCollection permissions) void
setProtectedClassMatcher
(ClassMatcher protectedClasses) Set the protected (system) classes patterns.void
setResourceAlias
(String alias, String uri) Set Resource Alias.void
setResourceAliases
(Map<String, String> map) void
Set theServer
to associate to thisHandler
.void
setServerClassMatcher
(ClassMatcher serverClasses) Deprecated, for removal: This API element is subject to removal in a future version.setServletSecurity
(jakarta.servlet.ServletRegistration.Dynamic registration, jakarta.servlet.ServletSecurityElement servletSecurityElement) Delegate for ServletRegistration.Dynamic.setServletSecurity methodvoid
setSystemClassMatcher
(ClassMatcher systemClasses) Deprecated, for removal: This API element is subject to removal in a future version.void
setThrowUnavailableOnStartupException
(boolean throwIfStartupException) void
Set the war of the webapp.void
setWarResource
(Resource war) Set the war of the webapp as aResource
.protected void
Finish constructing handlers and link them together.protected void
Continue thestartContext()
before callingsuper.startContext()
.protected void
protected void
Continue thestopContext()
before callingsuper.stopContext()
.toString()
Methods inherited from class org.eclipse.jetty.ee10.servlet.ServletContextHandler
addEventListener, addFilter, addFilter, addFilter, addFilter, addLocaleEncoding, addProgrammaticListener, addRoles, addServlet, addServlet, addServlet, addServlet, addServletContainerInitializer, addServletContainerInitializer, addServletContainerInitializer, callContextDestroyed, callContextInitialized, contextDestroyed, contextInitialized, doStop, dynamicHolderAdded, getContext, getContextPathEncoded, getCurrentServletContext, getCurrentServletContextHandler, getDefaultRequestCharacterEncoding, getDefaultResponseCharacterEncoding, getDefaultSecurityHandlerClass, getInitParameter, getInitParameterNames, getInitParams, getInvocationType, getLocaleEncoding, getLocaleEncoding, getLocaleEncodings, getLogger, getMaxFormContentSize, getMaxFormKeys, getObjectFactory, getRequestContextPath, getResourcePaths, getSecurityHandler, getServletContext, getServletContext, getServletContextHandler, getServletContextHandler, getServletHandler, getSessionHandler, getWelcomeFiles, handleByContextHandler, insertHandler, isDurableListener, isProgrammaticListener, isUsingSecurityManager, loadClass, newContext, newResource, newResource, newResource, newSecurityHandler, newServletContextRequest, newServletHandler, newSessionHandler, notifyEnterScope, notifyExitScope, requestDestroyed, requestInitialized, setDefaultRequestCharacterEncoding, setDefaultResponseCharacterEncoding, setDefaultSecurityHandlerClass, setHandler, setInitParameter, setLogger, setMaxFormContentSize, setMaxFormKeys, setSecurityHandler, setServletHandler, setSessionHandler, setTempDirectory, setUsingSecurityManager, setWelcomeFiles, wrapRequest, wrapResponse
Methods inherited from class org.eclipse.jetty.server.handler.ContextHandler
addAliasCheck, addVirtualHosts, checkAlias, checkVirtualHost, clearAliasChecks, clearAttributes, enterScope, exitScope, getAliasChecks, getAllowNullPathInContext, getAttribute, getAttributeNameSet, getBaseName, getBaseResource, getClassLoader, getClassPath, getContextHandler, getContextPath, getCrossContextHandler, getCurrentContext, getCurrentContext, getCurrentContextHandler, getDisplayName, getErrorHandler, getMimeTypes, getProtectedTargets, getTempDirectory, getVirtualHosts, handle, handleMovedPermanently, handleUnavailable, isAvailable, isCrossContextDispatchSupported, isProtectedTarget, isTempDirectoryPersistent, removeAttribute, removeVirtualHosts, setAliasChecks, setAllowNullPathInContext, setAttribute, setAvailable, setBaseResource, setBaseResourceAsPath, setBaseResourceAsString, setCrossContextDispatchSupported, setErrorHandler, setProtectedTargets, setTempDirectoryPersistent, setVirtualHosts
Methods inherited from class org.eclipse.jetty.server.Handler.Wrapper
getHandler
Methods inherited from class org.eclipse.jetty.server.Handler.AbstractContainer
findContainerOf, getDescendant, getDescendants, isDynamic, setDynamic
Methods inherited from class org.eclipse.jetty.server.Handler.Abstract
getServer
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addManaged, contains, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeans
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.util.Attributes
asAttributeMap, equals, hashCode
Methods inherited from interface org.eclipse.jetty.util.component.Container
getCachedBeans, getEventListeners
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
Methods inherited from interface org.eclipse.jetty.server.Handler.Container
getContainer, getDescendant, getDescendants, getDescendants
Methods inherited from interface org.eclipse.jetty.server.Handler.Singleton
getHandlers, getTail, setHandler
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, start, stop
Methods inherited from interface org.eclipse.jetty.ee10.webapp.WebAppClassLoader.Context
isServerResource, isSystemResource, newResource
-
Field Details
-
WEB_DEFAULTS_XML
- See Also:
-
SERVER_SYS_CLASSES
Deprecated, for removal: This API element is subject to removal in a future version.useWebAppClassLoading.PROTECTED_CLASSES_ATTRIBUTE
instead.- See Also:
-
SERVER_SRV_CLASSES
Deprecated, for removal: This API element is subject to removal in a future version.useWebAppClassLoading.HIDDEN_CLASSES_ATTRIBUTE
instead.- See Also:
-
__dftSystemClasses
Deprecated, for removal: This API element is subject to removal in a future version. -
__dftServerClasses
Deprecated, for removal: This API element is subject to removal in a future version.
-
-
Constructor Details
-
WebAppContext
public WebAppContext() -
WebAppContext
- Parameters:
contextPath
- The context pathwebApp
- The URL or filename of the webapp directory or war file.
-
WebAppContext
- Parameters:
contextPath
- The context pathwebApp
- The URL or filename of the webapp directory or war file.
-
WebAppContext
public WebAppContext(SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler) - Parameters:
sessionHandler
- SessionHandler for this web appsecurityHandler
- SecurityHandler for this web appservletHandler
- ServletHandler for this web apperrorHandler
- ErrorHandler for this web app
-
WebAppContext
public WebAppContext(String contextPath, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler, int options) - Parameters:
contextPath
- the context pathsessionHandler
- SessionHandler for this web appsecurityHandler
- SecurityHandler for this web appservletHandler
- ServletHandler for this web apperrorHandler
- ErrorHandler for this web appoptions
- the options (ServletContextHandler.SESSIONS
and/orServletContextHandler.SECURITY
)
-
-
Method Details
-
getCurrentWebAppContext
-
initializeDefaults
- Specified by:
initializeDefaults
in interfaceDeployable
-
isContextPathDefault
public boolean isContextPathDefault() -
setContextPath
- Overrides:
setContextPath
in classServletContextHandler
- Parameters:
contextPath
- The _contextPath to set.
-
setDefaultContextPath
-
setDisplayName
- Overrides:
setDisplayName
in classContextHandler
- Parameters:
servletContextName
- The servletContextName to set.
-
setResourceAlias
Set Resource Alias. Resource aliases map resource uri's within a context. They may optionally be used by a handler when looking for a resource.- Parameters:
alias
- the alias for a resourceuri
- the uri for the resource
-
getResourceAliases
-
setResourceAliases
-
getResourceAlias
-
removeResourceAlias
-
setClassLoader
- Overrides:
setClassLoader
in classContextHandler
-
getResourceFactory
-
getResource
Description copied from class:ServletContextHandler
Attempt to get a Resource from the Context.- Overrides:
getResource
in classServletContextHandler
- Parameters:
pathInContext
- the path within the base resource to attempt to get- Returns:
- the resource, or null if not available.
- Throws:
MalformedURLException
- if unable to form a Resource from the provided path
-
isConfigurationDiscovered
public boolean isConfigurationDiscovered()Is the context Automatically configured.- Returns:
- true if configuration discovery.
-
setConfigurationDiscovered
public void setConfigurationDiscovered(boolean discovered) Set the configuration discovery mode. If configuration discovery is set to true, then the JSR315 servlet 3.0 discovered configuration features are enabled. These are:- Web Fragments
- META-INF/resource directories
- Parameters:
discovered
- true if configuration discovery is enabled for automatic configuration from the context
-
preConfigure
Pre configure the web application.The method is normally called from
AbstractLifeCycle.start()
. It performs the discovery of the configurations to be applied to this context, specifically:- Instantiate the
Configuration
instances with a call toloadConfigurations()
. - Instantiates a classloader (if one is not already set)
- Calls the
Configuration.preConfigure(WebAppContext)
method of all Configuration instances.
- Throws:
Exception
- if unable to pre configure
- Instantiate the
-
configureClassLoader
Configure the contextClassLoader
, potentially wrapping it.- Parameters:
loader
- The loader initially set on this context bysetClassLoader(ClassLoader)
- Returns:
- Either the configured loader, or a new
ClassLoader
that uses the loader.
-
createTempDirectory
protected void createTempDirectory()Description copied from class:ContextHandler
Create the temporary directory. If the directory exists, but is not persistent, then it is first deleted and then recreated. Once created, this method is a noop if called again before stopping the context.
- Overrides:
createTempDirectory
in classContextHandler
-
configure
- Throws:
Exception
-
postConfigure
- Throws:
Exception
-
doStart
Description copied from class:ContainerLifeCycle
Starts the managed lifecycle beans in the order they were added.- Overrides:
doStart
in classServletContextHandler
- Throws:
AbstractLifeCycle.StopException
- If thrown, the lifecycle will immediately be stopped.Exception
- If there was a problem starting. Will cause a transition to FAILED state
-
destroy
public void destroy()Description copied from class:ContainerLifeCycle
Destroys the managed Destroyable beans in the reverse order they were added.- Specified by:
destroy
in interfaceDestroyable
- Overrides:
destroy
in classContextHandler
-
getConfigurationClasses
@ManagedAttribute(value="configuration classes used to configure webapp", readonly=true) public String[] getConfigurationClasses()- Returns:
- Returns the configurations.
-
getConfigurations
- Returns:
- Returns the configurations.
-
getDefaultsDescriptor
@ManagedAttribute(value="default web.xml deascriptor applied before standard web.xml", readonly=true) public String getDefaultsDescriptor()The default descriptor is a web.xml format file that is applied to the context before the standard WEB-INF/web.xml- Returns:
- Returns the defaultsDescriptor.
-
getOverrideDescriptor
The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml- Returns:
- Returns the Override Descriptor.
-
getOverrideDescriptors
@ManagedAttribute(value="web.xml deascriptors applied after standard web.xml", readonly=true) public 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- Returns:
- Returns the Override Descriptor list
-
getPermissions
- Specified by:
getPermissions
in interfaceWebAppClassLoader.Context
- Returns:
- Returns the permissions.
-
setHiddenClassMatcher
Set the hidden (server) classes patterns.These classes/packages are 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.
- Parameters:
hiddenClasses
- the server classes pattern
-
setProtectedClassMatcher
Set the protected (system) classes patterns.These classes/packages are provided by the JVM and cannot be replaced by classes of the same name from WEB-INF, regardless of the value of
setParentLoaderPriority(boolean)
.- Parameters:
protectedClasses
- the system classes pattern
-
addHiddenClassMatcher
Add a ClassMatcher for hidden (server) classes by combining with any existing matcher.- Parameters:
hiddenClasses
- The class matcher of patterns to add to the server ClassMatcher
-
addProtectedClassMatcher
Add a ClassMatcher for protected (system) classes by combining with any existing matcher.- Parameters:
protectedClasses
- The class matcher of patterns to add to the system ClassMatcher
-
getProtectedClassMatcher
- Returns:
- The ClassMatcher used to match System (protected) classes
-
getHiddenClassMatcher
- Returns:
- The ClassMatcher used to match Server (hidden) classes
-
getProtectedClasses
@ManagedAttribute(value="classes and packages protected by context classloader", readonly=true) public String[] getProtectedClasses() -
getHiddenClasses
@ManagedAttribute(value="classes and packages hidden by the context classloader", readonly=true) public String[] getHiddenClasses() -
isHiddenClass
Description copied from interface:ClassVisibilityChecker
Is the class a Hidden (Server) Class. A Server class is a class that is part of the implementation of the server and is NOT visible to a web application. The web application may provide its own implementation of the class, to be loaded from WEB-INF/lib or WEB-INF/classes- Specified by:
isHiddenClass
in interfaceClassVisibilityChecker
- Parameters:
clazz
- The fully qualified name of the class.- Returns:
- True if the class is a server class.
-
isProtectedClass
Description copied from interface:ClassVisibilityChecker
Is the class a Protected (System) Class. A System class is a class that is visible to a web application, but that cannot be overridden by the contents of WEB-INF/lib or WEB-INF/classes- Specified by:
isProtectedClass
in interfaceClassVisibilityChecker
- Parameters:
clazz
- The fully qualified name of the class.- Returns:
- True if the class is a system class.
-
isHiddenResource
- Specified by:
isHiddenResource
in interfaceWebAppClassLoader.Context
-
isProtectedResource
- Specified by:
isProtectedResource
in interfaceWebAppClassLoader.Context
-
setServerClassMatcher
@Deprecated(since="12.0.8", forRemoval=true) public void setServerClassMatcher(ClassMatcher serverClasses) Deprecated, for removal: This API element is subject to removal in a future version. -
setSystemClassMatcher
@Deprecated(since="12.0.8", forRemoval=true) public void setSystemClassMatcher(ClassMatcher systemClasses) Deprecated, for removal: This API element is subject to removal in a future version. -
addServerClassMatcher
@Deprecated(since="12.0.8", forRemoval=true) public void addServerClassMatcher(ClassMatcher serverClasses) Deprecated, for removal: This API element is subject to removal in a future version. -
addSystemClassMatcher
@Deprecated(since="12.0.8", forRemoval=true) public void addSystemClassMatcher(ClassMatcher systemClasses) Deprecated, for removal: This API element is subject to removal in a future version. -
getSystemClassMatcher
Deprecated, for removal: This API element is subject to removal in a future version. -
getServerClassMatcher
Deprecated, for removal: This API element is subject to removal in a future version. -
getSystemClasses
Deprecated, for removal: This API element is subject to removal in a future version. -
getServerClasses
Deprecated, for removal: This API element is subject to removal in a future version. -
isServerClass
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:ClassVisibilityChecker
Is the class a Server Class. A Server class is a class that is part of the implementation of the server and is NOT visible to a web application. The web application may provide its own implementation of the class, to be loaded from WEB-INF/lib or WEB-INF/classes- Specified by:
isServerClass
in interfaceClassVisibilityChecker
- Parameters:
clazz
- The fully qualified name of the class.- Returns:
- True if the class is a server class.
-
isSystemClass
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:ClassVisibilityChecker
Is the class a System Class. A System class is a class that is visible to a web application, but that cannot be overridden by the contents of WEB-INF/lib or WEB-INF/classes- Specified by:
isSystemClass
in interfaceClassVisibilityChecker
- Parameters:
clazz
- The fully qualified name of the class.- Returns:
- True if the class is a system class.
-
setServer
Description copied from interface:Handler
Set theServer
to associate to thisHandler
.- Specified by:
setServer
in interfaceHandler
- Overrides:
setServer
in classContextHandler
- Parameters:
server
- theServer
to associate to thisHandler
-
getWar
- Returns:
- Returns the war as a file or URL string (Resource).
The war may be different to the @link
ContextHandler.getBaseResource()
if the war has been expanded and/or copied.
-
getWebInf
- Throws:
IOException
-
isDistributable
- Returns:
- Returns the distributable.
-
isExtractWAR
- Returns:
- Returns the extractWAR.
-
isCopyWebDir
@ManagedAttribute(value="webdir copied on deploy (allows hot replacement on windows)", readonly=true) public boolean isCopyWebDir()- Returns:
- True if the webdir is copied (to allow hot replacement of jars on windows)
-
isCopyWebInf
public boolean isCopyWebInf()- Returns:
- True if the web-inf lib and classes directories are copied (to allow hot replacement of jars on windows)
-
isParentLoaderPriority
@ManagedAttribute(value="parent classloader given priority", readonly=true) public boolean isParentLoaderPriority()- Specified by:
isParentLoaderPriority
in interfaceWebAppClassLoader.Context
- 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). Default is false or can be set by the system property org.eclipse.jetty.server.webapp.parentLoaderPriority
-
loadConfigurations
protected void loadConfigurations() -
newConfigurations
-
newServletContextApi
- Overrides:
newServletContextApi
in classServletContextHandler
-
toString
- Overrides:
toString
in classContextHandler
-
dump
Description copied from interface:Dumpable
Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.- Specified by:
dump
in interfaceDumpable
- Overrides:
dump
in classServletContextHandler
- Parameters:
out
- The appendable to dump toindent
- The indent to apply after any new lines.- Throws:
IOException
- if unable to write to Appendable
-
setConfigurationClasses
- Parameters:
configurations
- The configuration class names. If setConfigurations is not called these classes are used to create a configurations array.
-
setConfigurationClasses
-
setConfigurations
- Parameters:
configurations
- The configurations to set.
-
setConfigurations
- Parameters:
configurations
- The configurations to set.
-
addConfiguration
-
getConfiguration
-
removeConfiguration
-
removeConfiguration
-
setDefaultsDescriptor
The default descriptor is a web.xml format file that is applied to the context before the standard WEB-INF/web.xml- Parameters:
defaultsDescriptor
- The defaultsDescriptor to set.
-
setOverrideDescriptor
The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml- Parameters:
overrideDescriptor
- The overrideDescritpor to set.
-
setOverrideDescriptors
The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml- Parameters:
overrideDescriptors
- The overrideDescriptors (file or URL) to set.
-
addOverrideDescriptor
The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml- Parameters:
overrideDescriptor
- The overrideDescriptor (file or URL) to add.
-
getDescriptor
- Returns:
- the web.xml descriptor to use. If set to null, WEB-INF/web.xml is used if it exists.
-
setDescriptor
Set the web.xml descriptor to use. If set to null, WEB-INF/web.xml is used if it exists..- Parameters:
descriptor
- the web.xml descriptor to use. If set to null, WEB-INF/web.xml is used if it exists.
-
setDistributable
public void setDistributable(boolean distributable) - Parameters:
distributable
- The distributable to set.
-
removeEventListener
Description copied from interface:Container
Remove an event listener.- Specified by:
removeEventListener
in interfaceContainer
- Specified by:
removeEventListener
in interfaceLifeCycle
- Overrides:
removeEventListener
in classServletContextHandler
- Parameters:
listener
- the listener to remove- Returns:
- true if the listener was removed
- See Also:
-
setExtractWAR
public void setExtractWAR(boolean extractWAR) - Parameters:
extractWAR
- True if war files are extracted
-
setCopyWebDir
public void setCopyWebDir(boolean copy) - Parameters:
copy
- True if the webdir is copied (to allow hot replacement of jars)
-
setCopyWebInf
public void setCopyWebInf(boolean copyWebInf) - Parameters:
copyWebInf
- True if the web-inf lib and classes directories are copied (to allow hot replacement of jars on windows)
-
setParentLoaderPriority
public void setParentLoaderPriority(boolean java2compliant) - Parameters:
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.parentLoaderPriority
-
setPermissions
- Parameters:
permissions
- The permissions to set.
-
setContextWhiteList
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. Setting this white list will enable a check when a servlet calledServletContextHandler.Context#getContext(String)
, validating that the uriInPath for the given webapp has been declaratively allows access to the context.- Parameters:
contextWhiteList
- the whitelist of contexts
-
setWar
Set the war of the webapp. From this value aContextHandler.setBaseResource(Resource)
value is computed byWebInfConfiguration
, which may be changed from the war URI by unpacking and/or copying.- Parameters:
war
- The war to set as a file name or URL.
-
setWarResource
Set the war of the webapp as aResource
.- Parameters:
war
- The war to set as a Resource.- See Also:
-
getExtraClasspath
@ManagedAttribute(value="extra classpath for context classloader", readonly=true) public List<Resource> getExtraClasspath()- Specified by:
getExtraClasspath
in interfaceWebAppClassLoader.Context
- Returns:
- Comma or semicolon separated path of filenames or URLs pointing to directories or jar files. Directories should end with '/'.
-
setExtraClasspath
Set the Extra ClassPath via delimited String.This is a convenience method for
setExtraClasspath(List)
- Parameters:
extraClasspath
- Comma or semicolon separated path of filenames or URLs pointing to directories or jar files. Directories should end with '/'.- See Also:
-
setExtraClasspath
-
isLogUrlOnStart
public boolean isLogUrlOnStart() -
setLogUrlOnStart
public void setLogUrlOnStart(boolean logOnStart) Sets whether or not the web app name and URL is logged on startup- Parameters:
logOnStart
- whether or not the log message is created
-
isAllowDuplicateFragmentNames
public boolean isAllowDuplicateFragmentNames() -
setAllowDuplicateFragmentNames
public void setAllowDuplicateFragmentNames(boolean allowDuplicateFragmentNames) -
startContext
Description copied from class:ServletContextHandler
Finish constructing handlers and link them together.- Overrides:
startContext
in classServletContextHandler
- Throws:
Exception
-
stopContext
- Overrides:
stopContext
in classServletContextHandler
- Throws:
Exception
-
startWebapp
Continue thestartContext()
before callingsuper.startContext()
.- Throws:
Exception
- If there was a problem starting
-
stopWebapp
Continue thestopContext()
before callingsuper.stopContext()
.- Throws:
Exception
- If there was a problem stopping
-
cleanupAfterStop
Prevent the temp directory from being deleted during the normal stop sequence, and require thatContextHandler.cleanupAfterStop()
is explicitly called after the webapp classloader is closed- Overrides:
cleanupAfterStop
in classContextHandler
- Throws:
Exception
-
setServletSecurity
public Set<String> setServletSecurity(jakarta.servlet.ServletRegistration.Dynamic registration, jakarta.servlet.ServletSecurityElement servletSecurityElement) Description copied from class:ServletContextHandler
Delegate for ServletRegistration.Dynamic.setServletSecurity method- Overrides:
setServletSecurity
in classServletContextHandler
- Parameters:
registration
- ServletRegistration.Dynamic instance that setServletSecurity was called onservletSecurityElement
- new security info- Returns:
- the set of exact URL mappings currently associated with the registration that are also present in the web.xml security constraints and thus will be unaffected by this call.
-
getMetaData
-
makeTempDirectory
Description copied from class:ContextHandler
Generate a reasonable name for the temp directory because one has not been explicitly configured by the user withContextHandler.setTempDirectory(File)
. The directory may also be created, if it is not persistent. If it is persistent it will be created as necessary byContextHandler.createTempDirectory()
later during the startup of the context.- Overrides:
makeTempDirectory
in classContextHandler
- Throws:
Exception
- IllegalStateException if the parent tmp directory does not exist, or IOException if the child tmp directory cannot be created.
-
getCanonicalNameForTmpDir
Description copied from class:ContextHandler
Create a canonical name for a context temp directory.The form of the name is:
"jetty-"+host+"-"+port+"-"+resourceBase+"-_"+context+"-"+virtualhost+"-"+randomdigits+".dir"
host and port uniquely identify the server context and virtual host uniquely identify the context randomdigits ensure every tmp directory is unique- Overrides:
getCanonicalNameForTmpDir
in classContextHandler
- Returns:
- the canonical name for the context temp directory
-
getResourceForTempDirName
If the webapp has no baseresource yet, use the war to make the temp directory name.- Overrides:
getResourceForTempDirName
in classContextHandler
- Returns:
- the baseresource if non null, or the war
-
addServerClasses
@Deprecated(since="12.0.8", forRemoval=true) public static void addServerClasses(Server server, String... patterns) Deprecated, for removal: This API element is subject to removal in a future version.Add a Server Class pattern to use for all WebAppContexts.- Parameters:
server
- TheServer
instance to add classes topatterns
- the patterns to use- See Also:
-
addSystemClasses
@Deprecated(since="12.0.8", forRemoval=true) public static void addSystemClasses(Server server, String... patterns) Deprecated, for removal: This API element is subject to removal in a future version.Add a System Class pattern to use for all WebAppContexts.- Parameters:
server
- TheServer
instance to add classes topatterns
- the patterns to use- See Also:
-
WebAppClassLoading.DEFAULT_HIDDEN_CLASSES