Class WebAppContext

java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.server.Handler.Abstract
org.eclipse.jetty.server.Handler.AbstractContainer
org.eclipse.jetty.server.Handler.Wrapper
org.eclipse.jetty.server.handler.ContextHandler
org.eclipse.jetty.ee11.servlet.ServletContextHandler
org.eclipse.jetty.ee11.webapp.WebAppContext
All Implemented Interfaces:
org.eclipse.jetty.ee.webapp.WebAppClassLoader.Context, org.eclipse.jetty.server.AliasCheck, org.eclipse.jetty.server.Deployable, org.eclipse.jetty.server.Handler, org.eclipse.jetty.server.Handler.Container, org.eclipse.jetty.server.Handler.Singleton, org.eclipse.jetty.server.Request.Handler, org.eclipse.jetty.util.Attributes, org.eclipse.jetty.util.ClassVisibilityChecker, org.eclipse.jetty.util.component.Container, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.LifeCycle, org.eclipse.jetty.util.thread.Invocable

@ManagedObject("Web Application ContextHandler") public class WebAppContext extends org.eclipse.jetty.ee11.servlet.ServletContextHandler implements org.eclipse.jetty.ee.webapp.WebAppClassLoader.Context, org.eclipse.jetty.server.Deployable
Web Application Context Handler.

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.

The class implements WebAppClassLoader.Context and thus the ClassVisibilityChecker API, which is used by any WebAppClassLoader to control visibility of classes to the context.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
     

    Nested classes/interfaces inherited from class org.eclipse.jetty.ee11.servlet.ServletContextHandler

    org.eclipse.jetty.ee11.servlet.ServletContextHandler.ContextStatus, org.eclipse.jetty.ee11.servlet.ServletContextHandler.JspConfig, org.eclipse.jetty.ee11.servlet.ServletContextHandler.JspPropertyGroup, org.eclipse.jetty.ee11.servlet.ServletContextHandler.ServletContainerInitializerCaller, org.eclipse.jetty.ee11.servlet.ServletContextHandler.ServletContainerInitializerStarter, org.eclipse.jetty.ee11.servlet.ServletContextHandler.ServletContextApi, org.eclipse.jetty.ee11.servlet.ServletContextHandler.ServletContextScopeListener, org.eclipse.jetty.ee11.servlet.ServletContextHandler.ServletRequestInfo, org.eclipse.jetty.ee11.servlet.ServletContextHandler.ServletResponseInfo, org.eclipse.jetty.ee11.servlet.ServletContextHandler.ServletScopedContext, org.eclipse.jetty.ee11.servlet.ServletContextHandler.TagLib

    Nested classes/interfaces inherited from class org.eclipse.jetty.server.handler.ContextHandler

    org.eclipse.jetty.server.handler.ContextHandler.Availability, org.eclipse.jetty.server.handler.ContextHandler.ContextScopeListener, org.eclipse.jetty.server.handler.ContextHandler.ScopedContext

    Nested classes/interfaces inherited from class org.eclipse.jetty.server.Handler.Abstract

    org.eclipse.jetty.server.Handler.Abstract.NonBlocking

    Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener, org.eclipse.jetty.util.component.AbstractLifeCycle.StopException

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.Attributes

    org.eclipse.jetty.util.Attributes.Layer, org.eclipse.jetty.util.Attributes.Lazy, org.eclipse.jetty.util.Attributes.Mapped, org.eclipse.jetty.util.Attributes.Synthetic, org.eclipse.jetty.util.Attributes.Wrapper

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container

    org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable

    org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.Dumpable.DumpAppendable

    Nested classes/interfaces inherited from interface org.eclipse.jetty.server.Handler

    org.eclipse.jetty.server.Handler.Abstract, org.eclipse.jetty.server.Handler.AbstractContainer, org.eclipse.jetty.server.Handler.Collection, org.eclipse.jetty.server.Handler.Container, org.eclipse.jetty.server.Handler.Sequence, org.eclipse.jetty.server.Handler.Singleton, org.eclipse.jetty.server.Handler.Wrapper

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable

    org.eclipse.jetty.util.thread.Invocable.Callable, org.eclipse.jetty.util.thread.Invocable.InvocationType, org.eclipse.jetty.util.thread.Invocable.ReadyTask, org.eclipse.jetty.util.thread.Invocable.Task

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

    org.eclipse.jetty.util.component.LifeCycle.Listener

    Nested classes/interfaces inherited from interface org.eclipse.jetty.server.Request.Handler

    org.eclipse.jetty.server.Request.Handler.AbortException
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Deprecated, for removal: This API element is subject to removal in a future version.
    use WebAppClassLoading.HIDDEN_CLASSES_ATTRIBUTE instead.
    static final String
    Deprecated, for removal: This API element is subject to removal in a future version.
    use WebAppClassLoading.PROTECTED_CLASSES_ATTRIBUTE instead.
    static final String
     

    Fields inherited from class org.eclipse.jetty.ee11.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, BASE_RESOURCE, CONFIGURATION_CLASSES, CONTAINER_SCAN_JARS, CONTEXT_HANDLER_CLASS, CONTEXT_PATH, DEFAULT_CONTEXT_PATH, DEFAULTS_DESCRIPTOR, DIR_ALLOWED, ENVIRONMENT, ENVIRONMENT_XML, EXTRACT_WARS, MAIN_PATH, OTHER_PATHS, PARENT_LOADER_PRIORITY, SCI_EXCLUSION_PATTERN, SCI_ORDER, TEMP_DIR, WAR, WEBINF_SCAN_JARS

    Fields inherited from interface org.eclipse.jetty.util.component.Dumpable

    LEGEND

    Fields inherited from interface org.eclipse.jetty.util.thread.Invocable

    __nonBlocking, NOOP
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    WebAppContext(String webApp, String contextPath)
     
    WebAppContext(String contextPath, org.eclipse.jetty.ee11.servlet.SessionHandler sessionHandler, org.eclipse.jetty.security.SecurityHandler securityHandler, org.eclipse.jetty.ee11.servlet.ServletHandler servletHandler, org.eclipse.jetty.ee11.servlet.ErrorHandler errorHandler, int options)
     
    WebAppContext(org.eclipse.jetty.ee11.servlet.SessionHandler sessionHandler, org.eclipse.jetty.security.SecurityHandler securityHandler, org.eclipse.jetty.ee11.servlet.ServletHandler servletHandler, org.eclipse.jetty.ee11.servlet.ErrorHandler errorHandler)
     
    WebAppContext(org.eclipse.jetty.util.resource.Resource webApp, String contextPath)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addConfiguration(Configuration... configuration)
     
    void
    addHiddenClassMatcher(org.eclipse.jetty.util.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.xml
    void
    addProtectedClassMatcher(org.eclipse.jetty.util.ClassMatcher protectedClasses)
    Add a ClassMatcher for protected (system) classes by combining with any existing matcher.
    static void
    addServerClasses(org.eclipse.jetty.server.Server server, String... patterns)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use WebAppClassLoading.addProtectedClasses(Server, String...)
    static void
    addSystemClasses(org.eclipse.jetty.server.Server server, String... patterns)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use WebAppClassLoading.addHiddenClasses(Server, String...)
    protected void
    Prevent the temp directory from being deleted during the normal stop sequence, and require that ContextHandler.cleanupAfterStop() is explicitly called after the webapp classloader is closed
    boolean
     
    protected ClassLoader
    Configure the context ClassLoader, potentially wrapping it.
    protected void
     
    void
     
    protected void
     
    void
    dump(Appendable out, String indent)
     
    protected String
     
    <T> T
    getConfiguration(Class<? extends T> configClass)
     
     
     
     
    The default descriptor is a web.xml format file that is applied to the context before the standard WEB-INF/web.xml
     
    List<org.eclipse.jetty.util.resource.Resource>
     
     
    org.eclipse.jetty.util.ClassMatcher
     
     
    The override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml
    An override descriptor is a web.xml format file that is applied to the context after the standard WEB-INF/web.xml
     
     
    org.eclipse.jetty.util.ClassMatcher
     
    org.eclipse.jetty.util.resource.Resource
    getResource(String pathInContext)
     
     
     
    org.eclipse.jetty.util.resource.ResourceFactory
     
    protected org.eclipse.jetty.util.resource.Resource
    If the webapp has no baseresource yet, use the war to make the temp directory name.
    Get an exception that caused the webapp to be unavailable
     
    org.eclipse.jetty.util.resource.Resource
     
    protected void
    initializeDefault(String keyName, Object value)
     
    boolean
     
    boolean
    Is the context Automatically configured.
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    protected void
     
    protected void
     
    protected Configurations
     
    org.eclipse.jetty.ee11.servlet.ServletContextHandler.ServletContextApi
     
    void
     
    void
    Pre configure the web application.
    void
    removeConfiguration(Class<? extends Configuration>... configurations)
     
    void
     
    boolean
     
     
    void
     
    void
    setAllowDuplicateFragmentNames(boolean allowDuplicateFragmentNames)
     
    void
    setBaseResource(org.eclipse.jetty.util.resource.Resource baseResource)
     
    void
     
    void
    setConfigurationClasses(String[] configurations)
     
    void
     
    void
    setConfigurationDiscovered(boolean discovered)
    Set the configuration discovery mode.
    void
    setConfigurations(Configuration[] configurations)
     
    void
     
    void
    setContextWhiteList(String... contextWhiteList)
    Set the context white list
    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)
    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<org.eclipse.jetty.util.resource.Resource> extraClasspath)
     
    void
    setExtractWAR(boolean extractWAR)
     
    void
    setHiddenClassMatcher(org.eclipse.jetty.util.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 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
     
    void
    setProtectedClassMatcher(org.eclipse.jetty.util.ClassMatcher protectedClasses)
    Set the protected (system) classes patterns.
    void
    Set Resource Alias.
    void
     
    void
    setServer(org.eclipse.jetty.server.Server server)
     
    setServletSecurity(jakarta.servlet.ServletRegistration.Dynamic registration, jakarta.servlet.ServletSecurityElement servletSecurityElement)
     
    void
    setThrowUnavailableOnStartupException(boolean throwIfStartupException)
     
    void
    Set the war of the webapp.
    void
    setWarResource(org.eclipse.jetty.util.resource.Resource war)
    Set the war of the webapp as a Resource.
    protected void
     
    protected void
    Continue the startContext() before calling super.startContext().
    protected void
     
    protected void
    Continue the stopContext() before calling super.stopContext().
     

    Methods inherited from class org.eclipse.jetty.ee11.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, setContextPath, 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, addEncodings, addMimeTypes, 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, initializeDefaults, initializeDefaultsComplete, isAvailable, isContextPathDefault, isCrossContextDispatchSupported, isProtectedTarget, isTempDirectoryPersistent, removeAttribute, removeVirtualHosts, setAliasChecks, setAllowNullPathInContext, setAttribute, setAvailable, setBaseResourceAsPath, setBaseResourceAsString, setCrossContextDispatchSupported, setDefaultContextPath, setEncodings, setErrorHandler, setMimeTypes, 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 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.ClassVisibilityChecker

    isServerClass, isSystemClass

    Methods inherited from interface org.eclipse.jetty.util.component.Container

    getCachedBeans, getEventListeners

    Methods inherited from interface org.eclipse.jetty.server.Deployable

    initializeDefaults

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable

    dumpSelf

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer

    isDumpable

    Methods inherited from interface org.eclipse.jetty.server.Handler

    getServer

    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.ee.webapp.WebAppClassLoader.Context

    isHiddenClass, isHiddenResource, isProtectedClass, isProtectedResource, newResource
  • Field Details

    • WEB_DEFAULTS_XML

      public static final String WEB_DEFAULTS_XML
      See Also:
    • SERVER_SYS_CLASSES

      @Deprecated(forRemoval=true, since="12.0.9") public static final String SERVER_SYS_CLASSES
      Deprecated, for removal: This API element is subject to removal in a future version.
      use WebAppClassLoading.PROTECTED_CLASSES_ATTRIBUTE instead.
      See Also:
    • SERVER_SRV_CLASSES

      @Deprecated(forRemoval=true, since="12.0.9") public static final String SERVER_SRV_CLASSES
      Deprecated, for removal: This API element is subject to removal in a future version.
      use WebAppClassLoading.HIDDEN_CLASSES_ATTRIBUTE instead.
      See Also:
  • Constructor Details

    • WebAppContext

      public WebAppContext()
    • WebAppContext

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

      public WebAppContext(org.eclipse.jetty.util.resource.Resource webApp, String contextPath)
      Parameters:
      webApp - The URL or filename of the webapp directory or war file.
      contextPath - The context path
    • WebAppContext

      public WebAppContext(org.eclipse.jetty.ee11.servlet.SessionHandler sessionHandler, org.eclipse.jetty.security.SecurityHandler securityHandler, org.eclipse.jetty.ee11.servlet.ServletHandler servletHandler, org.eclipse.jetty.ee11.servlet.ErrorHandler errorHandler)
      Parameters:
      sessionHandler - SessionHandler for this web app
      securityHandler - SecurityHandler for this web app
      servletHandler - ServletHandler for this web app
      errorHandler - ErrorHandler for this web app
    • WebAppContext

      public WebAppContext(String contextPath, org.eclipse.jetty.ee11.servlet.SessionHandler sessionHandler, org.eclipse.jetty.security.SecurityHandler securityHandler, org.eclipse.jetty.ee11.servlet.ServletHandler servletHandler, org.eclipse.jetty.ee11.servlet.ErrorHandler errorHandler, int options)
      Parameters:
      contextPath - the context path
      sessionHandler - SessionHandler for this web app
      securityHandler - SecurityHandler for this web app
      servletHandler - ServletHandler for this web app
      errorHandler - ErrorHandler for this web app
      options - the options (ServletContextHandler.SESSIONS and/or ServletContextHandler.SECURITY)
  • Method Details

    • getCurrentWebAppContext

      public static WebAppContext getCurrentWebAppContext()
    • initializeDefault

      protected void initializeDefault(String keyName, Object value)
      Overrides:
      initializeDefault in class org.eclipse.jetty.server.handler.ContextHandler
    • setBaseResource

      public void setBaseResource(org.eclipse.jetty.util.resource.Resource baseResource)
      Overrides:
      setBaseResource in class org.eclipse.jetty.server.handler.ContextHandler
    • setDisplayName

      public void setDisplayName(String servletContextName)
      Overrides:
      setDisplayName in class org.eclipse.jetty.server.handler.ContextHandler
      Parameters:
      servletContextName - The servletContextName to set.
    • getUnavailableException

      public Throwable getUnavailableException()
      Get an exception that caused the webapp to be unavailable
      Returns:
      A throwable if the webapp is unavailable or null
    • setResourceAlias

      public void setResourceAlias(String alias, String uri)
      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 resource
      uri - the uri for the resource
    • getResourceAliases

      public Map<String,String> getResourceAliases()
    • setResourceAliases

      public void setResourceAliases(Map<String,String> map)
    • getResourceAlias

      public String getResourceAlias(String path)
    • removeResourceAlias

      public String removeResourceAlias(String alias)
    • setClassLoader

      public void setClassLoader(ClassLoader classLoader)
      Overrides:
      setClassLoader in class org.eclipse.jetty.server.handler.ContextHandler
    • getResourceFactory

      public org.eclipse.jetty.util.resource.ResourceFactory getResourceFactory()
    • getResource

      public org.eclipse.jetty.util.resource.Resource getResource(String pathInContext) throws MalformedURLException
      Overrides:
      getResource in class org.eclipse.jetty.ee11.servlet.ServletContextHandler
      Throws:
      MalformedURLException
    • 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

      public void preConfigure() throws Exception
      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:

      Throws:
      Exception - if unable to pre configure
    • configureClassLoader

      protected ClassLoader configureClassLoader(ClassLoader loader)
      Configure the context ClassLoader, potentially wrapping it.
      Parameters:
      loader - The loader initially set on this context by setClassLoader(ClassLoader)
      Returns:
      Either the configured loader, or a new ClassLoader that uses the loader.
    • createTempDirectory

      protected void createTempDirectory()
      Overrides:
      createTempDirectory in class org.eclipse.jetty.server.handler.ContextHandler
    • configure

      public boolean configure() throws Exception
      Throws:
      Exception
    • postConfigure

      public void postConfigure() throws Exception
      Throws:
      Exception
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.eclipse.jetty.ee11.servlet.ServletContextHandler
      Throws:
      Exception
    • destroy

      public void destroy()
      Specified by:
      destroy in interface org.eclipse.jetty.util.component.Destroyable
      Overrides:
      destroy in class org.eclipse.jetty.server.handler.ContextHandler
    • getConfigurationClasses

      @ManagedAttribute(value="configuration classes used to configure webapp", readonly=true) public String[] getConfigurationClasses()
      Returns:
      Returns the configurations.
    • getConfigurations

      public 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

      public String 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

      public PermissionCollection getPermissions()
      Specified by:
      getPermissions in interface org.eclipse.jetty.ee.webapp.WebAppClassLoader.Context
      Returns:
      Returns the permissions.
    • setHiddenClassMatcher

      public void setHiddenClassMatcher(org.eclipse.jetty.util.ClassMatcher hiddenClasses)
      Set the hidden (server) classes patterns.

      This ClassMatcher is used to implement the ClassVisibilityChecker contract for the context by determining which classes and resources from the server and environment classloader are hidden from the context. The context may have its own copy of these classes/resources in WEB-INF/lib or WEB-INF/classes.

      Parameters:
      hiddenClasses - the server classes pattern
    • setProtectedClassMatcher

      public void setProtectedClassMatcher(org.eclipse.jetty.util.ClassMatcher protectedClasses)
      Set the protected (system) classes patterns.

      This ClassMatcher is used to implement the ClassVisibilityChecker contract for the context by determining which classes and resources from the server and environment classloader may not be overridden by the context. The context may not have its own copy of these classes/resources.

      Parameters:
      protectedClasses - the system classes pattern
    • addHiddenClassMatcher

      public void addHiddenClassMatcher(org.eclipse.jetty.util.ClassMatcher hiddenClasses)
      Add a ClassMatcher for hidden (server) classes by combining with any existing matcher.
      Parameters:
      hiddenClasses - The class matcher of patterns to add to the hidden (server) ClassMatcher
      See Also:
    • addProtectedClassMatcher

      public void addProtectedClassMatcher(org.eclipse.jetty.util.ClassMatcher protectedClasses)
      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
      See Also:
    • getProtectedClassMatcher

      public org.eclipse.jetty.util.ClassMatcher getProtectedClassMatcher()
      Specified by:
      getProtectedClassMatcher in interface org.eclipse.jetty.ee.webapp.WebAppClassLoader.Context
      Returns:
      The ClassMatcher used to match protected (system) classes to implement the ClassVisibilityChecker contract.
      See Also:
    • getHiddenClassMatcher

      public org.eclipse.jetty.util.ClassMatcher getHiddenClassMatcher()
      Specified by:
      getHiddenClassMatcher in interface org.eclipse.jetty.ee.webapp.WebAppClassLoader.Context
      Returns:
      The ClassMatcher used to match hidden (server) classes to implement the ClassVisibilityChecker contract.
      See Also:
    • getProtectedClasses

      @ManagedAttribute(value="classes and packages protected by context classloader", readonly=true) public String[] getProtectedClasses()
      Specified by:
      getProtectedClasses in interface org.eclipse.jetty.ee.webapp.WebAppClassLoader.Context
    • getHiddenClasses

      @ManagedAttribute(value="classes and packages hidden by the context classloader", readonly=true) public String[] getHiddenClasses()
      Specified by:
      getHiddenClasses in interface org.eclipse.jetty.ee.webapp.WebAppClassLoader.Context
    • setServer

      public void setServer(org.eclipse.jetty.server.Server server)
      Specified by:
      setServer in interface org.eclipse.jetty.server.Handler
      Overrides:
      setServer in class org.eclipse.jetty.server.handler.ContextHandler
    • getWar

      @ManagedAttribute(value="war file location", readonly=true) public String 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

      public org.eclipse.jetty.util.resource.Resource getWebInf() throws IOException
      Throws:
      IOException
    • isDistributable

      @ManagedAttribute("web application distributable") public boolean isDistributable()
      Returns:
      Returns the distributable.
    • isExtractWAR

      @ManagedAttribute(value="extract war", readonly=true) public boolean 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 interface org.eclipse.jetty.ee.webapp.WebAppClassLoader.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

      protected Configurations newConfigurations()
    • newServletContextApi

      public org.eclipse.jetty.ee11.servlet.ServletContextHandler.ServletContextApi newServletContextApi()
      Overrides:
      newServletContextApi in class org.eclipse.jetty.ee11.servlet.ServletContextHandler
    • toString

      public String toString()
      Overrides:
      toString in class org.eclipse.jetty.server.handler.ContextHandler
    • dump

      public void dump(Appendable out, String indent) throws IOException
      Specified by:
      dump in interface org.eclipse.jetty.util.component.Dumpable
      Overrides:
      dump in class org.eclipse.jetty.ee11.servlet.ServletContextHandler
      Throws:
      IOException
    • setConfigurationClasses

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

      public void setConfigurationClasses(List<String> configurations)
    • setConfigurations

      public void setConfigurations(Configurations configurations)
      Parameters:
      configurations - The configurations to set.
    • setConfigurations

      public void setConfigurations(Configuration[] configurations)
      Parameters:
      configurations - The configurations to set.
    • addConfiguration

      public void addConfiguration(Configuration... configuration)
    • getConfiguration

      public <T> T getConfiguration(Class<? extends T> configClass)
    • removeConfiguration

      public void removeConfiguration(Configuration... configurations)
    • removeConfiguration

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

      public 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
      Parameters:
      defaultsDescriptor - The defaultsDescriptor to set.
    • setOverrideDescriptor

      public 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
      Parameters:
      overrideDescriptor - The overrideDescritpor to set.
    • setOverrideDescriptors

      public 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
      Parameters:
      overrideDescriptors - The overrideDescriptors (file or URL) to set.
    • addOverrideDescriptor

      public 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
      Parameters:
      overrideDescriptor - The overrideDescriptor (file or URL) to add.
    • getDescriptor

      @ManagedAttribute(value="standard web.xml descriptor", readonly=true) public String getDescriptor()
      Returns:
      the web.xml descriptor to use. If set to null, WEB-INF/web.xml is used if it exists.
    • setDescriptor

      public void setDescriptor(String descriptor)
      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

      public boolean removeEventListener(EventListener listener)
      Specified by:
      removeEventListener in interface org.eclipse.jetty.util.component.Container
      Specified by:
      removeEventListener in interface org.eclipse.jetty.util.component.LifeCycle
      Overrides:
      removeEventListener in class org.eclipse.jetty.ee11.servlet.ServletContextHandler
    • 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

      public void setPermissions(PermissionCollection permissions)
      Parameters:
      permissions - The permissions to set.
    • setContextWhiteList

      public 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. Setting this white list will enable a check when a servlet called ServletContextHandler.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

      public void setWar(String war)
      Set the war of the webapp. From this value a setBaseResource(Resource) value is computed by WebInfConfiguration, 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

      public void setWarResource(org.eclipse.jetty.util.resource.Resource war)
      Set the war of the webapp as a Resource.
      Parameters:
      war - The war to set as a Resource.
      See Also:
    • getExtraClasspath

      @ManagedAttribute(value="extra classpath for context classloader", readonly=true) public List<org.eclipse.jetty.util.resource.Resource> getExtraClasspath()
      Specified by:
      getExtraClasspath in interface org.eclipse.jetty.ee.webapp.WebAppClassLoader.Context
      Returns:
      Comma or semicolon separated path of filenames or URLs pointing to directories or jar files. Directories should end with '/'.
    • setExtraClasspath

      public void setExtraClasspath(String extraClasspath)
      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

      public void setExtraClasspath(List<org.eclipse.jetty.util.resource.Resource> extraClasspath)
    • 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)
    • setThrowUnavailableOnStartupException

      public void setThrowUnavailableOnStartupException(boolean throwIfStartupException)
    • isThrowUnavailableOnStartupException

      public boolean isThrowUnavailableOnStartupException()
    • resolveMetaData

      public void resolveMetaData() throws Exception
      Throws:
      Exception
    • startContext

      protected void startContext() throws Exception
      Overrides:
      startContext in class org.eclipse.jetty.ee11.servlet.ServletContextHandler
      Throws:
      Exception
    • stopContext

      protected void stopContext() throws Exception
      Overrides:
      stopContext in class org.eclipse.jetty.ee11.servlet.ServletContextHandler
      Throws:
      Exception
    • startWebapp

      protected void startWebapp() throws Exception
      Continue the startContext() before calling super.startContext().
      Throws:
      Exception - If there was a problem starting
    • stopWebapp

      protected void stopWebapp() throws Exception
      Continue the stopContext() before calling super.stopContext().
      Throws:
      Exception - If there was a problem stopping
    • cleanupAfterStop

      protected void cleanupAfterStop() throws Exception
      Prevent the temp directory from being deleted during the normal stop sequence, and require that ContextHandler.cleanupAfterStop() is explicitly called after the webapp classloader is closed
      Overrides:
      cleanupAfterStop in class org.eclipse.jetty.server.handler.ContextHandler
      Throws:
      Exception
    • setServletSecurity

      public Set<String> setServletSecurity(jakarta.servlet.ServletRegistration.Dynamic registration, jakarta.servlet.ServletSecurityElement servletSecurityElement)
      Overrides:
      setServletSecurity in class org.eclipse.jetty.ee11.servlet.ServletContextHandler
    • getMetaData

      public MetaData getMetaData()
    • makeTempDirectory

      protected void makeTempDirectory() throws Exception
      Overrides:
      makeTempDirectory in class org.eclipse.jetty.server.handler.ContextHandler
      Throws:
      Exception
    • getCanonicalNameForTmpDir

      protected String getCanonicalNameForTmpDir()
      Overrides:
      getCanonicalNameForTmpDir in class org.eclipse.jetty.server.handler.ContextHandler
    • getResourceForTempDirName

      protected org.eclipse.jetty.util.resource.Resource getResourceForTempDirName()
      If the webapp has no baseresource yet, use the war to make the temp directory name.
      Overrides:
      getResourceForTempDirName in class org.eclipse.jetty.server.handler.ContextHandler
      Returns:
      the baseresource if non null, or the war
    • addServerClasses

      @Deprecated(since="12.0.8", forRemoval=true) public static void addServerClasses(org.eclipse.jetty.server.Server server, String... patterns)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use WebAppClassLoading.addProtectedClasses(Server, String...)
      Add a Server Class pattern to use for all WebAppContexts.
      Parameters:
      server - The Server instance to add classes to
      patterns - the patterns to use
      See Also:
    • addSystemClasses

      @Deprecated(since="12.0.8", forRemoval=true) public static void addSystemClasses(org.eclipse.jetty.server.Server server, String... patterns)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use WebAppClassLoading.addHiddenClasses(Server, String...)
      Add a System Class pattern to use for all WebAppContexts.
      Parameters:
      server - The Server instance to add classes to
      patterns - the patterns to use
      See Also: