Class InitFacesContext


public class InitFacesContext extends NoOpFacesContext
A special, minimal implementation of FacesContext used at application initialization time. The ExternalContext returned by this FacesContext only exposes the ApplicationMap.
  • Constructor Details

    • InitFacesContext

      public InitFacesContext(jakarta.servlet.ServletContext servletContext)
  • Method Details

    • getAttributes

      public Map<Object,Object> getAttributes()
      Description copied from class: FacesContext

      Return a mutable Map representing the attributes associated wth this FacesContext instance. This Map is useful to store attributes that you want to go out of scope when the Faces lifecycle for the current request ends, which is not always the same as the request ending, especially in the case of Jakarta Servlet filters that are invoked after the Faces lifecycle for this request completes. Accessing this Map does not cause any events to fire, as is the case with the other maps: for request, session, and application scope. When FacesContext.release() is invoked, the attributes must be cleared.

      The Map returned by this method is not associated with the request. If you would like to get or set request attributes, see ExternalContext.getRequestMap().

      The default implementation throws UnsupportedOperationException and is provided for the sole purpose of not breaking existing applications that extend this class.

      Overrides:
      getAttributes in class FacesContext
      Returns:
      mutable Map representing the attributes associated wth this FacesContext instance.
    • getExternalContext

      public ExternalContext getExternalContext()
      Description copied from class: FacesContext

      Return the ExternalContext instance for this FacesContext instance.

      It is valid to call this method during application startup or shutdown. If called during application startup or shutdown, this method returns an ExternalContext instance with the special behaviors indicated in the javadoc for that class. Methods document as being valid to call during application startup or shutdown must be supported.

      Specified by:
      getExternalContext in class FacesContext
      Returns:
      instance of ExternalContext
    • getViewRoot

      public UIViewRoot getViewRoot()
      Description copied from class: FacesContext

      Return the root component that is associated with the this request.

      It is valid to call this method during application startup or shutdown. If called during application startup or shutdown, this method returns a new UIViewRoot with its locale set to Locale.getDefault().

      Specified by:
      getViewRoot in class FacesContext
      Returns:
      UIViewRoot instance.
    • getELContext

      public jakarta.el.ELContext getELContext()
      Description copied from class: FacesContext

      Return the ELContext instance for this FacesContext instance. This ELContext instance has the same lifetime and scope as the FacesContext instance with which it is associated, and may be created lazily the first time this method is called for a given FacesContext instance. Upon creation of the ELContext instance, the implementation must take the following action:

      • Call the ELContext.putContext(java.lang.Class<?>, java.lang.Object) method on the instance, passing in FacesContext.class and the this reference for the FacesContext instance itself.

      • If the Collection returned by Application.getELContextListeners() is non-empty, create an instance of ELContextEvent and pass it to each ELContextListener instance in the Collection by calling the ELContextListener.contextCreated(jakarta.el.ELContextEvent) method.

      Overrides:
      getELContext in class FacesContext
      Returns:
      instance of ELContext.
    • setELContext

      public void setELContext(jakarta.el.ELContext elContext)
    • getApplication

      public Application getApplication()
      Description copied from class: FacesContext

      Return the Application instance associated with this web application.

      It is valid to call this method during application startup or shutdown. If called during application startup or shutdown, returns the correct current Application instance.

      Specified by:
      getApplication in class FacesContext
      Returns:
      the Application instance associated with this web application.
    • isProjectStage

      public boolean isProjectStage(ProjectStage stage)
      Description copied from class: FacesContext

      Return true if the current ProjectStage as returned by the Application instance is equal to stage, otherwise return false

      Overrides:
      isProjectStage in class FacesContext
      Parameters:
      stage - the ProjectStage to check
      Returns:
      boolean indicating whether the application has the same stage.
    • release

      public void release()
      Description copied from class: FacesContext

      Release any resources associated with this FacesContext instance. Faces implementations may choose to pool instances in the associated FacesContextFactory to avoid repeated object creation and garbage collection. After release() is called on a FacesContext instance (until the FacesContext instance has been recycled by the implementation for re-use), calling any other methods will cause an IllegalStateException to be thrown.

      If a call was made to FacesContext.getAttributes() during the processing for this request, the implementation must call clear() on the Map returned from getAttributes(), and then de-allocate the data-structure behind that Map.

      The implementation must call FacesContext.setCurrentInstance(jakarta.faces.context.FacesContext) passing null to remove the association between this thread and this dead FacesContext instance.

      Specified by:
      release in class FacesContext
    • releaseCurrentInstance

      public void releaseCurrentInstance()
    • addInitContextEntryForCurrentThread

      public void addInitContextEntryForCurrentThread()
    • removeInitContextEntryForCurrentThread

      public void removeInitContextEntryForCurrentThread()
    • addServletContextEntryForInitContext

      public void addServletContextEntryForInitContext(jakarta.servlet.ServletContext servletContext)
    • removeServletContextEntryForInitContext

      public void removeServletContextEntryForInitContext()
    • cleanupInitMaps

      public static void cleanupInitMaps(jakarta.servlet.ServletContext servletContext)
      Clean up entries from the threadInitContext and initContextServletContext maps using a ServletContext. First remove entry(s) with matching ServletContext from initContextServletContext map. Then remove entries from threadInitContext map where the entry value(s) match the initFacesContext (associated with the ServletContext).
      Parameters:
      servletContext - the involved servlet context
    • getInstance

      public static InitFacesContext getInstance(jakarta.servlet.ServletContext servletContext)
    • reInitializeExternalContext

      public void reInitializeExternalContext(jakarta.servlet.ServletContext sc)