Class ViewScopeStorageInSession.ActiveBeanStorages

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

@RequestScoped protected 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
    Modifier
    Constructor
    Description
    protected
     
  • 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 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, 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

      protected 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.
    • 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, release all bean storages which it still has acquired.