Class ContextualStorage

java.lang.Object
com.vaadin.cdi.util.ContextualStorage
All Implemented Interfaces:
Serializable

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.
Since:
15.0
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    ContextualStorage(jakarta.enterprise.inject.spi.BeanManager beanManager, boolean concurrent, boolean passivationCapable)
    Creates a new contextual storage.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    createContextualInstance(jakarta.enterprise.context.spi.Contextual<T> bean, jakarta.enterprise.context.spi.CreationalContext<T> creationalContext)
    Creates a new contextual instance of the given bean and stores it in this storage.
    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.
    Gets the underlying storage map.
    boolean
    Checks whether the ContextualStorage might get accessed concurrently.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ContextualStorage

      public ContextualStorage(jakarta.enterprise.inject.spi.BeanManager beanManager, boolean concurrent, boolean passivationCapable)
      Creates a new contextual storage.
      Parameters:
      beanManager - is needed for serialisation
      concurrent - whether the ContextualStorage might get accessed concurrently by different threads
      passivationCapable - whether the storage is for passivation capable Scopes
  • Method Details

    • getStorage

      public Map<Object,ContextualInstanceInfo<?>> getStorage()
      Gets the underlying storage map.
      Returns:
      the underlying storage map.
    • isConcurrent

      public boolean isConcurrent()
      Checks whether the ContextualStorage might get accessed concurrently.
      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)
      Creates a new contextual instance of the given bean and stores it in this storage. For concurrent storages, an already existing instance is returned instead of creating a new one.
      Type Parameters:
      T - the type of the contextual instance
      Parameters:
      bean - the bean to create an instance of
      creationalContext - the creational context to use for creating the instance
      Returns:
      the contextual instance
    • 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.
      Type Parameters:
      T - the type of the contextual instance
      Parameters:
      bean - the bean to get the key for
      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.
      Parameters:
      beanKey - the key of the bean, as returned by getBeanKey(Contextual)
      Returns:
      the bean for the given key
      See Also: