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