Class ViewScopeStorageInSession

java.lang.Object
org.omnifaces.cdi.viewscope.ViewScopeStorageInSession
All Implemented Interfaces:
Serializable, ViewScopeStorage

@SessionScoped public class ViewScopeStorageInSession extends Object implements ViewScopeStorage, Serializable
Stores view scoped bean instances in a LRU map in HTTP session.
Since:
2.6
Author:
Bauke Scholtz
See Also:
  • Constructor Details

    • ViewScopeStorageInSession

      public ViewScopeStorageInSession()
  • Method Details

    • postConstructSession

      @PostConstruct public void postConstructSession()
      Create a new LRU map of active view scopes with maximum weighted capacity depending on several context params. See javadoc of ViewScoped for details.
    • getBeanStorageId

      public UUID getBeanStorageId()
      Description copied from interface: ViewScopeStorage
      Returns currently active bean storage ID, or null if it does not exist.
      Specified by:
      getBeanStorageId in interface ViewScopeStorage
      Returns:
      Currently active bean storage ID, or null if it does not exist.
    • getBeanStorage

      public BeanStorage getBeanStorage(UUID beanStorageId)
      Description copied from interface: ViewScopeStorage
      Returns the bean storage identified by given ID, or null if it does not exist.
      Specified by:
      getBeanStorage in interface ViewScopeStorage
      Parameters:
      beanStorageId - The bean storage identifier.
      Returns:
      The bean storage identified by given ID, or null if it does not exist.
    • setBeanStorage

      public void setBeanStorage(UUID beanStorageId, BeanStorage beanStorage)
      Sets the given bean storage as the one of the current view. It is only put in the LRU map of active view scopes when the state of the current view is saved, see ViewScopeUnloadScriptRenderer and ViewScopeStateManager. Until then it is pending in the current HTTP request, and when the Faces lifecycle of the current HTTP request ends without saving the state of the current view, then its beans are destroyed, because the client never received a view on which the unload script could destroy them.
      Specified by:
      setBeanStorage in interface ViewScopeStorage
      Parameters:
      beanStorageId - The bean storage identifier.
      beanStorage - The bean storage.
    • destroyBeans

      public void destroyBeans(FacesContext context, UUID beanStorageId)
      Destroys all beans associated with given bean storage identifier. When a concurrent HTTP request is still using them, then they are destroyed as soon as the last one has finished. See ViewScopeStorageInSession.ActiveBeanStorages.
      Parameters:
      context - The involved faces context.
      beanStorageId - The bean storage identifier.
    • isRecentlyUnloaded

      public boolean isRecentlyUnloaded(FacesContext context)
      Returns true if given faces context is recently unloaded.
      Parameters:
      context - The involved faces context.
      Returns:
      true if given faces context is recently unloaded.
      Since:
      2.7.27
    • preDestroySession

      @PreDestroy public void preDestroySession()
      This method is invoked during session destroy, in that case destroy all beans in all active view scopes.