Package com.vaadin.cdi.context
Class UIScopedContext.ContextualStorageManager
java.lang.Object
com.vaadin.cdi.context.UIScopedContext.ContextualStorageManager
- All Implemented Interfaces:
Serializable
- Enclosing class:
UIScopedContext
Manages the contextual storages of UI scoped beans within a Vaadin
session, keyed by UI id.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidDestroys all active beans in the storage of the given key and removes the storage.protected voidDestroys all active beans in all managed storages and removes the storages.getContextualStorage(boolean createIfNotExist) Gets the contextual storage of the current UI.protected ContextualStoragegetContextualStorage(Integer key, boolean createIfNotExist) Gets the contextual storage for the given key.Gets the keys of all managed storages.protected ContextualStoragenewContextualStorage(Integer uiId) Creates a new contextual storage for the given key.protected voidMoves the contextual storage stored for one key to another key.
-
Constructor Details
-
ContextualStorageManager
public ContextualStorageManager()Creates a new storage manager.
-
-
Method Details
-
getContextualStorage
Gets the contextual storage of the current UI.- Parameters:
createIfNotExist- whether to create the storage if it does not exist yet- Returns:
- the contextual storage, or
nullif it does not exist andcreateIfNotExistisfalse - Throws:
IllegalStateException- if there is no current UI
-
newContextualStorage
Creates a new contextual storage for the given key.- Parameters:
uiId- the context key- Returns:
- the new contextual storage
-
getContextualStorage
Gets the contextual storage for the given key.- Parameters:
key- the context keycreateIfNotExist- whether to create the storage if it does not exist yet- Returns:
- the contextual storage, or
nullif it does not exist andcreateIfNotExistisfalse
-
relocate
Moves the contextual storage stored for one key to another key. Does nothing if there is no storage for the source key.- Parameters:
from- the current key of the storageto- the new key of the storage
-
destroyAll
@PreDestroy protected void destroyAll()Destroys all active beans in all managed storages and removes the storages. -
destroy
Destroys all active beans in the storage of the given key and removes the storage.- Parameters:
key- the context key
-
getKeySet
Gets the keys of all managed storages.- Returns:
- an unmodifiable set of the context keys
-