Package org.apache.myfaces.cdi.util
Class ContextualStorage
- java.lang.Object
-
- org.apache.myfaces.cdi.util.ContextualStorage
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ViewScopeContextualStorage
public class ContextualStorage extends Object implements Serializable
This Storage holds all information needed for storing Contextual Instances in a Context. It also addresses Serialisation in case of passivating scopes.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
activated
protected jakarta.enterprise.inject.spi.BeanManager
beanManager
protected boolean
concurrent
protected Map<Object,ContextualInstanceInfo<?>>
contextualInstances
-
Constructor Summary
Constructors Constructor Description ContextualStorage()
ContextualStorage(jakarta.enterprise.inject.spi.BeanManager beanManager, boolean concurrent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activate()
<T> T
createContextualInstance(jakarta.enterprise.context.spi.Contextual<T> bean, jakarta.enterprise.context.spi.CreationalContext<T> creationalContext)
void
deactivate()
jakarta.enterprise.context.spi.Contextual<?>
getBean(Object beanKey)
Restores the Bean from its beanKey.<T> Object
getBeanKey(jakarta.enterprise.context.spi.Contextual<T> bean)
If the context is a passivating scope then we return the passivationId of the Bean.Map<Object,ContextualInstanceInfo<?>>
getStorage()
boolean
isActivated()
boolean
isConcurrent()
-
-
-
Field Detail
-
contextualInstances
protected Map<Object,ContextualInstanceInfo<?>> contextualInstances
-
beanManager
protected jakarta.enterprise.inject.spi.BeanManager beanManager
-
concurrent
protected boolean concurrent
-
activated
protected transient volatile boolean activated
-
-
Constructor Detail
-
ContextualStorage
public ContextualStorage()
-
ContextualStorage
public ContextualStorage(jakarta.enterprise.inject.spi.BeanManager beanManager, boolean concurrent)
- Parameters:
beanManager
- is needed for serialisationconcurrent
- whether the ContextualStorage might get accessed concurrently by different threads
-
-
Method Detail
-
getStorage
public Map<Object,ContextualInstanceInfo<?>> getStorage()
- Returns:
- the underlying storage map.
-
isConcurrent
public boolean isConcurrent()
- Returns:
- whether the ContextualStorage might get accessed concurrently by different threads.
-
createContextualInstance
public <T> T createContextualInstance(jakarta.enterprise.context.spi.Contextual<T> bean, jakarta.enterprise.context.spi.CreationalContext<T> creationalContext)
- Type Parameters:
T
-- Parameters:
bean
-creationalContext
-- Returns:
-
getBeanKey
public <T> Object getBeanKey(jakarta.enterprise.context.spi.Contextual<T> bean)
If the context is a passivating scope then we return the passivationId of the Bean. Otherwise we use the Bean directly.- Parameters:
bean
-- Returns:
- the key to use in the context map
-
getBean
public jakarta.enterprise.context.spi.Contextual<?> getBean(Object beanKey)
Restores the Bean from its beanKey.
-
isActivated
public boolean isActivated()
-
activate
public void activate()
-
deactivate
public void deactivate()
-
-