Class ViewScopeStorageInSession.ActiveBeanStorages

java.lang.Object
org.omnifaces.cdi.viewscope.ViewScopeStorageInSession.ActiveBeanStorages
Enclosing class:
ViewScopeStorageInSession

@RequestScoped public static class ViewScopeStorageInSession.ActiveBeanStorages extends Object
Holds the bean storages which are in use by the current HTTP request.

The LRU map of active view scopes is bound to a maximum capacity, so a request can have its bean storage evicted by concurrent requests within the same session before it has finished. Acquiring the bean storage for the duration of the request guarantees that the request keeps resolving the same bean storage and that its beans are not prematurely destroyed by the eviction. An evicted bean storage is instead destroyed as soon as the last request using it has finished.

Since:
3.14.22
Author:
Bauke Scholtz
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    acquire(UUID beanStorageId, BeanStorage beanStorage)
    Acquires the given bean storage for the duration of the current HTTP request.
    protected void
    acquirePending(UUID beanStorageId, BeanStorage beanStorage)
    Acquires the given new bean storage for the duration of the current HTTP request, and marks it as pending until activate(UUID).
    protected BeanStorage
    activate(UUID beanStorageId)
    Marks the bean storage identified by the given bean storage identifier as no longer pending.
    protected BeanStorage
    getBeanStorage(UUID beanStorageId)
    Returns the bean storage which the current HTTP request has acquired under the given bean storage identifier, or null if there is none.
    protected void
    When the current HTTP request is about to be destroyed, destroy the beans of all bean storages which are still pending, and release all bean storages which it still has acquired.
    protected void
    release(UUID beanStorageId)
    Releases the bean storage identified by the given bean storage identifier, if the current HTTP request has acquired it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ActiveBeanStorages

      public ActiveBeanStorages()
  • Method Details

    • getBeanStorage

      protected BeanStorage getBeanStorage(UUID beanStorageId)
      Returns the bean storage which the current HTTP request has acquired under the given bean storage identifier, or null if there is none.
      Parameters:
      beanStorageId - The bean storage identifier.
      Returns:
      The acquired bean storage, or null if there is none.
    • acquire

      protected boolean acquire(UUID beanStorageId, BeanStorage beanStorage)
      Acquires the given bean storage for the duration of the current HTTP request. This is a no-op when it has already been acquired by the current HTTP request.
      Parameters:
      beanStorageId - The bean storage identifier.
      beanStorage - The bean storage.
      Returns:
      false when the beans of the given bean storage have meanwhile been destroyed by a concurrent eviction, in which case a new bean storage must be created.
    • acquirePending

      protected void acquirePending(UUID beanStorageId, BeanStorage beanStorage)
      Acquires the given new bean storage for the duration of the current HTTP request, and marks it as pending until activate(UUID). When the Faces lifecycle of the current HTTP request ends while it is still pending, then its beans are destroyed.
      Parameters:
      beanStorageId - The bean storage identifier.
      beanStorage - The new bean storage.
      Since:
      3.14.28
    • activate

      protected BeanStorage activate(UUID beanStorageId)
      Marks the bean storage identified by the given bean storage identifier as no longer pending. The returned bean storage is already acquired by the current HTTP request, so it is safe to put it in the LRU map, where a concurrent request could immediately evict it.
      Parameters:
      beanStorageId - The bean storage identifier.
      Returns:
      The bean storage if it was pending, else null.
      Since:
      3.14.28
    • release

      protected void release(UUID beanStorageId)
      Releases the bean storage identified by the given bean storage identifier, if the current HTTP request has acquired it. This is invoked when the view scope is explicitly destroyed, such as during an unload or a navigation, so that the current HTTP request will no longer resolve it.
      Parameters:
      beanStorageId - The bean storage identifier.
    • preDestroyRequest

      @PreDestroy protected void preDestroyRequest()
      When the current HTTP request is about to be destroyed, destroy the beans of all bean storages which are still pending, and release all bean storages which it still has acquired. Pending bean storages are normally already destroyed at the end of the Faces lifecycle, but not when it was aborted by an exception, nor when they were acquired after it had ended.