Module org.omnifaces
Package org.omnifaces.cdi.viewscope
Class ViewScopeStorageInSession.ActiveBeanStorages
java.lang.Object
org.omnifaces.cdi.viewscope.ViewScopeStorageInSession.ActiveBeanStorages
- Enclosing class:
- ViewScopeStorageInSession
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 -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanacquire(UUID beanStorageId, BeanStorage beanStorage) Acquires the given bean storage for the duration of the current HTTP request.protected voidacquirePending(UUID beanStorageId, BeanStorage beanStorage) Acquires the given new bean storage for the duration of the current HTTP request, and marks it as pending untilactivate(UUID).protected BeanStorageMarks the bean storage identified by the given bean storage identifier as no longer pending.protected BeanStoragegetBeanStorage(UUID beanStorageId) Returns the bean storage which the current HTTP request has acquired under the given bean storage identifier, ornullif there is none.protected voidWhen 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 voidReleases the bean storage identified by the given bean storage identifier, if the current HTTP request has acquired it.
-
Constructor Details
-
ActiveBeanStorages
public ActiveBeanStorages()
-
-
Method Details
-
getBeanStorage
Returns the bean storage which the current HTTP request has acquired under the given bean storage identifier, ornullif there is none.- Parameters:
beanStorageId- The bean storage identifier.- Returns:
- The acquired bean storage, or
nullif there is none.
-
acquire
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:
falsewhen 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
Acquires the given new bean storage for the duration of the current HTTP request, and marks it as pending untilactivate(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
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
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
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.
-