Class ContextualStorage

java.lang.Object
com.vaadin.quarkus.context.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:
1.0
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    ContextualStorage(boolean concurrent)
    Creates a new instance of 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 contextual instance of the given bean and stores it.
    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 map that holds the contextual instances.
    boolean
    Gets whether the storage is thread-safe.

    Methods inherited from class java.lang.Object

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

    • ContextualStorage

      public ContextualStorage(boolean concurrent)
      Creates a new instance of storage.
      Parameters:
      concurrent - whether the ContextualStorage might get accessed concurrently by different threads
  • Method Details

    • getStorage

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

      public boolean isConcurrent()
      Gets whether the storage is thread-safe.
      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 contextual instance of the given bean and stores it. In a concurrent storage, the instance another thread already created for the bean is returned instead.
      Type Parameters:
      T - contextual instance type
      Parameters:
      bean - the contextual type
      creationalContext - a context
      Returns:
      a created 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 - bean type
      Parameters:
      bean - the contextual type
      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 - a bean key
      Returns:
      the contextual type
      See Also: