Class ContextFacade

  • All Implemented Interfaces:
    jakarta.servlet.ServletContext, Container, Context, Lifecycle, Pipeline, Context

    public class ContextFacade
    extends WebModule
    Facade object which masks the internal Context object from the web application.
    Author:
    Amy Roh
    • Constructor Detail

      • ContextFacade

        public ContextFacade​(File docRoot,
                             String contextRoot,
                             ClassLoader classLoader)
        Construct a new instance of this class, associated with the specified Context instance.
        Parameters:
        docRoot -
        contextRoot -
        classLoader -
    • Method Detail

      • getAppName

        public String getAppName()
      • setAppName

        public void setAppName​(String name)
      • getDocRoot

        public File getDocRoot()
      • getContextPath

        public String getContextPath()
        Description copied from class: StandardContext
        Returns the context path of the web application.
        Specified by:
        getContextPath in interface jakarta.servlet.ServletContext
        Overrides:
        getContextPath in class StandardContext
      • getContext

        public jakarta.servlet.ServletContext getContext​(String uripath)
        Description copied from class: StandardContext
        Return a ServletContext object that corresponds to a specified URI on the server.
        Specified by:
        getContext in interface jakarta.servlet.ServletContext
        Overrides:
        getContext in class StandardContext
      • getMajorVersion

        public int getMajorVersion()
        Description copied from class: StandardContext
        Return the major version of the Java Servlet API that we implement.
        Specified by:
        getMajorVersion in interface jakarta.servlet.ServletContext
        Overrides:
        getMajorVersion in class StandardContext
      • getMinorVersion

        public int getMinorVersion()
        Description copied from class: StandardContext
        Return the minor version of the Java Servlet API that we implement.
        Specified by:
        getMinorVersion in interface jakarta.servlet.ServletContext
        Overrides:
        getMinorVersion in class StandardContext
      • getEffectiveMajorVersion

        public int getEffectiveMajorVersion()
        Specified by:
        getEffectiveMajorVersion in interface jakarta.servlet.ServletContext
        Overrides:
        getEffectiveMajorVersion in class StandardContext
      • getEffectiveMinorVersion

        public int getEffectiveMinorVersion()
        Specified by:
        getEffectiveMinorVersion in interface jakarta.servlet.ServletContext
        Overrides:
        getEffectiveMinorVersion in class StandardContext
      • getMimeType

        public String getMimeType​(String file)
        Description copied from class: StandardContext
        Return the MIME type of the specified file, or null if the MIME type cannot be determined.
        Specified by:
        getMimeType in interface jakarta.servlet.ServletContext
        Overrides:
        getMimeType in class StandardContext
      • getResourcePaths

        public Set<String> getResourcePaths​(String path)
        Description copied from class: StandardContext
        Return a Set containing the resource paths of resources member of the specified collection. Each path will be a String starting with a "/" character. The returned set is immutable.
        Specified by:
        getResourcePaths in interface jakarta.servlet.ServletContext
        Overrides:
        getResourcePaths in class StandardContext
      • getResourceAsStream

        public InputStream getResourceAsStream​(String path)
        Description copied from class: StandardContext
        Return the requested resource as an InputStream. The path must be specified according to the rules described under getResource. If no such resource can be identified, return null.
        Specified by:
        getResourceAsStream in interface jakarta.servlet.ServletContext
        Overrides:
        getResourceAsStream in class StandardContext
      • getRequestDispatcher

        public jakarta.servlet.RequestDispatcher getRequestDispatcher​(String path)
        Description copied from class: StandardContext
        Return a RequestDispatcher instance that acts as a wrapper for the resource at the given path. The path must begin with a "/" and is interpreted as relative to the current context root.
        Specified by:
        getRequestDispatcher in interface jakarta.servlet.ServletContext
        Overrides:
        getRequestDispatcher in class StandardContext
      • getNamedDispatcher

        public jakarta.servlet.RequestDispatcher getNamedDispatcher​(String name)
        Description copied from class: StandardContext
        Return a RequestDispatcher object that acts as a wrapper for the named servlet.
        Specified by:
        getNamedDispatcher in interface jakarta.servlet.ServletContext
        Overrides:
        getNamedDispatcher in class StandardContext
      • log

        public void log​(String msg)
        Description copied from class: StandardContext
        Writes the specified message to a servlet log file.
        Specified by:
        log in interface jakarta.servlet.ServletContext
        Overrides:
        log in class StandardContext
        Parameters:
        msg - Message to be logged
      • log

        public void log​(String message,
                        Throwable throwable)
        Description copied from class: StandardContext
        Writes the specified message and exception to a servlet log file.
        Specified by:
        log in interface jakarta.servlet.ServletContext
        Overrides:
        log in class StandardContext
        Parameters:
        message - Message to be logged
        throwable - Related exception
      • getRealPath

        public String getRealPath​(String path)
        Description copied from class: StandardContext
        Return the real path corresponding to the given virtual path, or null if the container was unable to perform the translation
        Specified by:
        getRealPath in interface jakarta.servlet.ServletContext
        Overrides:
        getRealPath in class StandardContext
      • getServerInfo

        public String getServerInfo()
        Description copied from class: StandardContext
        Return the name and version of the servlet container.
        Specified by:
        getServerInfo in interface jakarta.servlet.ServletContext
        Overrides:
        getServerInfo in class StandardContext
      • getInitParameter

        public String getInitParameter​(String name)
        Description copied from class: StandardContext
        Return the value of the specified initialization parameter, or null if this parameter does not exist.
        Specified by:
        getInitParameter in interface jakarta.servlet.ServletContext
        Overrides:
        getInitParameter in class StandardContext
      • getInitParameterNames

        public Enumeration<String> getInitParameterNames()
        Description copied from class: StandardContext
        Return the names of the context's initialization parameters, or an empty enumeration if the context has no initialization parameters.
        Specified by:
        getInitParameterNames in interface jakarta.servlet.ServletContext
        Overrides:
        getInitParameterNames in class StandardContext
      • setInitParameter

        public boolean setInitParameter​(String name,
                                        String value)
        Specified by:
        setInitParameter in interface jakarta.servlet.ServletContext
        Overrides:
        setInitParameter in class StandardContext
        Returns:
        true if the context initialization parameter with the given name and value was set successfully on this ServletContext, and false if it was not set because this ServletContext already contains a context initialization parameter with a matching name
      • getAttribute

        public Object getAttribute​(String name)
        Description copied from class: StandardContext
        Return the value of the specified context attribute, if any; otherwise return null.
        Specified by:
        getAttribute in interface jakarta.servlet.ServletContext
        Overrides:
        getAttribute in class StandardContext
      • getAttributeNames

        public Enumeration<String> getAttributeNames()
        Description copied from class: StandardContext
        Return an enumeration of the names of the context attributes associated with this context.
        Specified by:
        getAttributeNames in interface jakarta.servlet.ServletContext
        Overrides:
        getAttributeNames in class StandardContext
      • setAttribute

        public void setAttribute​(String name,
                                 Object object)
        Description copied from class: StandardContext
        Bind the specified value with the specified context attribute name, replacing any existing value for that name.
        Specified by:
        setAttribute in interface jakarta.servlet.ServletContext
        Overrides:
        setAttribute in class StandardContext
      • removeAttribute

        public void removeAttribute​(String name)
        Description copied from class: StandardContext
        Remove the context attribute with the specified name, if any.
        Specified by:
        removeAttribute in interface jakarta.servlet.ServletContext
        Overrides:
        removeAttribute in class StandardContext
      • getServletContextName

        public String getServletContextName()
        Description copied from class: StandardContext
        Return the display name of this web application.
        Specified by:
        getServletContextName in interface jakarta.servlet.ServletContext
        Overrides:
        getServletContextName in class StandardContext
      • getAddedServlets

        public Map<String,​String> getAddedServlets()
        Returns previously added servlets
      • addServlet

        public jakarta.servlet.ServletRegistration.Dynamic addServlet​(String servletName,
                                                                      String className)
        Specified by:
        addServlet in interface jakarta.servlet.ServletContext
        Overrides:
        addServlet in class StandardContext
      • addServletFacade

        public jakarta.servlet.ServletRegistration.Dynamic addServletFacade​(String servletName,
                                                                            String className)
      • addServlet

        public jakarta.servlet.ServletRegistration.Dynamic addServlet​(String servletName,
                                                                      Class<? extends jakarta.servlet.Servlet> servletClass)
        Specified by:
        addServlet in interface jakarta.servlet.ServletContext
        Overrides:
        addServlet in class StandardContext
      • addServlet

        public jakarta.servlet.ServletRegistration.Dynamic addServlet​(String servletName,
                                                                      jakarta.servlet.Servlet servlet)
        Specified by:
        addServlet in interface jakarta.servlet.ServletContext
        Overrides:
        addServlet in class StandardContext
      • addServletMapping

        public Set<String> addServletMapping​(String name,
                                             String[] urlPatterns)
        Description copied from class: StandardContext
        Adds the given servlet mappings to this Context.

        If any of the specified URL patterns are already mapped to a different Servlet, no updates will be performed.

        Overrides:
        addServletMapping in class StandardContext
        Parameters:
        name - the Servlet name
        urlPatterns - the URL patterns
        Returns:
        the (possibly empty) Set of URL patterns that are already mapped to a different Servlet
      • createServlet

        public <T extends jakarta.servlet.Servlet> T createServlet​(Class<T> clazz)
                                                            throws jakarta.servlet.ServletException
        Description copied from class: StandardContext
        Instantiates the given Servlet class and performs any required resource injection into the new Servlet instance before returning it.
        Specified by:
        createServlet in interface jakarta.servlet.ServletContext
        Overrides:
        createServlet in class StandardContext
        Throws:
        jakarta.servlet.ServletException
      • getServletRegistration

        public jakarta.servlet.ServletRegistration getServletRegistration​(String servletName)
        Description copied from class: StandardContext
        Gets the ServletRegistration corresponding to the servlet with the given servletName.
        Specified by:
        getServletRegistration in interface jakarta.servlet.ServletContext
        Overrides:
        getServletRegistration in class StandardContext
      • getServletRegistrations

        public Map<String,​? extends jakarta.servlet.ServletRegistration> getServletRegistrations()
        Description copied from class: StandardContext
        Gets a Map of the ServletRegistration objects corresponding to all currently registered servlets.
        Specified by:
        getServletRegistrations in interface jakarta.servlet.ServletContext
        Overrides:
        getServletRegistrations in class StandardContext
      • getServletNameFilterMappings

        public Map<String,​String> getServletNameFilterMappings()
      • getUrlPatternFilterMappings

        public Map<String,​String> getUrlPatternFilterMappings()
      • addFilterFacade

        public jakarta.servlet.FilterRegistration.Dynamic addFilterFacade​(String filterName,
                                                                          String className)
      • addFilter

        public jakarta.servlet.FilterRegistration.Dynamic addFilter​(String filterName,
                                                                    String className)
        Description copied from class: StandardContext
        Adds the filter with the given name and class name to this servlet context.
        Specified by:
        addFilter in interface jakarta.servlet.ServletContext
        Overrides:
        addFilter in class StandardContext
      • addFilterMap

        public void addFilterMap​(FilterMap filterMap,
                                 boolean isMatchAfter)
        Description copied from class: StandardContext
        Add a filter mapping to this Context.
        Overrides:
        addFilterMap in class StandardContext
        Parameters:
        filterMap - The filter mapping to be added
        isMatchAfter - true if the given filter mapping should be matched against requests after any declared filter mappings of this servlet context, and false if it is supposed to be matched before any declared filter mappings of this servlet context
      • addFilter

        public jakarta.servlet.FilterRegistration.Dynamic addFilter​(String filterName,
                                                                    jakarta.servlet.Filter filter)
        Specified by:
        addFilter in interface jakarta.servlet.ServletContext
        Overrides:
        addFilter in class StandardContext
      • addFilter

        public jakarta.servlet.FilterRegistration.Dynamic addFilter​(String filterName,
                                                                    Class<? extends jakarta.servlet.Filter> filterClass)
        Description copied from class: StandardContext
        Adds the filter with the given name and class type to this servlet context.
        Specified by:
        addFilter in interface jakarta.servlet.ServletContext
        Overrides:
        addFilter in class StandardContext
      • createFilter

        public <T extends jakarta.servlet.Filter> T createFilter​(Class<T> clazz)
                                                          throws jakarta.servlet.ServletException
        Description copied from class: StandardContext
        Instantiates the given Filter class and performs any required resource injection into the new Filter instance before returning it.
        Specified by:
        createFilter in interface jakarta.servlet.ServletContext
        Overrides:
        createFilter in class StandardContext
        Throws:
        jakarta.servlet.ServletException
      • getFilterRegistration

        public jakarta.servlet.FilterRegistration getFilterRegistration​(String filterName)
        Description copied from class: StandardContext
        Gets the FilterRegistration corresponding to the filter with the given filterName.
        Specified by:
        getFilterRegistration in interface jakarta.servlet.ServletContext
        Overrides:
        getFilterRegistration in class StandardContext
      • getFilterRegistrations

        public Map<String,​? extends jakarta.servlet.FilterRegistration> getFilterRegistrations()
        Description copied from class: StandardContext
        Gets a Map of the FilterRegistration objects corresponding to all currently registered filters.
        Specified by:
        getFilterRegistrations in interface jakarta.servlet.ServletContext
        Overrides:
        getFilterRegistrations in class StandardContext
      • getSessionCookieConfig

        public jakarta.servlet.SessionCookieConfig getSessionCookieConfig()
        Description copied from class: PwcWebModule
        Gets the session tracking cookie configuration of this ServletContext.
        Specified by:
        getSessionCookieConfig in interface Context
        Specified by:
        getSessionCookieConfig in interface jakarta.servlet.ServletContext
        Overrides:
        getSessionCookieConfig in class PwcWebModule
        Returns:
        the session tracking cookie configuration of this ServletContext.
      • setSessionTrackingModes

        public void setSessionTrackingModes​(Set<jakarta.servlet.SessionTrackingMode> sessionTrackingModes)
        Description copied from class: StandardContext
        Sets the session tracking modes that are to become effective for this ServletContext.
        Specified by:
        setSessionTrackingModes in interface jakarta.servlet.ServletContext
        Overrides:
        setSessionTrackingModes in class StandardContext
      • getDefaultSessionTrackingModes

        public Set<jakarta.servlet.SessionTrackingMode> getDefaultSessionTrackingModes()
        Description copied from class: StandardContext
        Gets the session tracking modes that are supported by default for this ServletContext.
        Specified by:
        getDefaultSessionTrackingModes in interface jakarta.servlet.ServletContext
        Overrides:
        getDefaultSessionTrackingModes in class StandardContext
        Returns:
        set of the session tracking modes supported by default for this ServletContext
      • getEffectiveSessionTrackingModes

        public Set<jakarta.servlet.SessionTrackingMode> getEffectiveSessionTrackingModes()
        Description copied from class: StandardContext
        Gets the session tracking modes that are in effect for this ServletContext.
        Specified by:
        getEffectiveSessionTrackingModes in interface jakarta.servlet.ServletContext
        Overrides:
        getEffectiveSessionTrackingModes in class StandardContext
        Returns:
        set of the session tracking modes in effect for this ServletContext
      • addListener

        public void addListener​(String className)
        Description copied from class: StandardContext
        Adds the listener with the given class name to this ServletContext.
        Specified by:
        addListener in interface jakarta.servlet.ServletContext
        Overrides:
        addListener in class StandardContext
        Parameters:
        className - the fully qualified class name of the listener
      • getListeners

        public List<String> getListeners()
      • addListener

        public <T extends EventListener> void addListener​(T t)
        Description copied from class: StandardContext
        Adds the given listener instance to this ServletContext.
        Specified by:
        addListener in interface Context
        Specified by:
        addListener in interface jakarta.servlet.ServletContext
        Overrides:
        addListener in class StandardContext
        Parameters:
        t - the listener to be added
      • addListener

        public void addListener​(Class<? extends EventListener> listenerClass)
        Description copied from class: StandardContext
        Adds a listener of the given class type to this ServletContext.
        Specified by:
        addListener in interface Context
        Specified by:
        addListener in interface jakarta.servlet.ServletContext
        Overrides:
        addListener in class StandardContext
        Parameters:
        listenerClass - the class from which to instantiate of the listener
      • createListener

        public <T extends EventListener> T createListener​(Class<T> clazz)
                                                   throws jakarta.servlet.ServletException
        Description copied from class: StandardContext
        Instantiates the given EventListener class and performs any required resource injection into the new EventListener instance before returning it.
        Specified by:
        createListener in interface jakarta.servlet.ServletContext
        Overrides:
        createListener in class StandardContext
        Throws:
        jakarta.servlet.ServletException
      • getJspConfigDescriptor

        public jakarta.servlet.descriptor.JspConfigDescriptor getJspConfigDescriptor()
        Description copied from class: StandardContext
        Gets the <jsp-config> related configuration that was aggregated over the web.xml and web-fragment.xml resources of the web application represented by this ServletContext.
        Specified by:
        getJspConfigDescriptor in interface jakarta.servlet.ServletContext
        Overrides:
        getJspConfigDescriptor in class StandardContext
      • getClassLoader

        public ClassLoader getClassLoader()
        Description copied from class: StandardContext
        Gets the class loader of the web application represented by this ServletContext.
        Specified by:
        getClassLoader in interface jakarta.servlet.ServletContext
        Overrides:
        getClassLoader in class StandardContext
      • declareRoles

        public void declareRoles​(String... roleNames)
        Specified by:
        declareRoles in interface jakarta.servlet.ServletContext
        Overrides:
        declareRoles in class WebModule
      • setPath

        public void setPath​(String path)
        Description copied from class: StandardContext
        Set the context path for this Context.

        IMPLEMENTATION NOTE: The context path is used as the "name" of a Context, because it must be unique.

        Specified by:
        setPath in interface Context
        Specified by:
        setPath in interface Context
        Overrides:
        setPath in class StandardContext
        Parameters:
        path - The new context path
      • setDefaultWebXml

        public void setDefaultWebXml​(String defaultWebXml)
        Description copied from class: StandardContext
        Set the location of the default web xml that will be used. If not absolute, it'll be made relative to the engine's base dir ( which defaults to catalina.base system property ). XXX If a file is not found - we can attempt a getResource()
        Specified by:
        setDefaultWebXml in interface Context
        Overrides:
        setDefaultWebXml in class StandardContext
        Parameters:
        defaultWebXml - the defaultWebXml path to be used
      • getUnwrappedContext

        public WebModule getUnwrappedContext()
        Gets the underlying StandardContext to which this ContextFacade is ultimately delegating.
        Returns:
        The underlying StandardContext
      • setUnwrappedContext

        public void setUnwrappedContext​(WebModule wm)
      • setDirectoryListing

        public void setDirectoryListing​(boolean directoryListing)
        Enables or disables directory listings on this Context.
        Specified by:
        setDirectoryListing in interface Context
        Overrides:
        setDirectoryListing in class StandardContext
        Parameters:
        directoryListing - true if directory listings are to be enabled on this Context, false otherwise
      • isDirectoryListing

        public boolean isDirectoryListing()
        Description copied from class: StandardContext
        Checks whether directory listings are enabled or disabled on this Context.
        Specified by:
        isDirectoryListing in interface Context
        Overrides:
        isDirectoryListing in class StandardContext
        Returns:
        true if directory listings are enabled on this Context, false otherwise