Package com.vaadin.cdi.context
Class VaadinSessionScopedContext
java.lang.Object
com.vaadin.cdi.util.AbstractContext
com.vaadin.cdi.context.VaadinSessionScopedContext
- All Implemented Interfaces:
jakarta.enterprise.context.spi.Context
Context for
@VaadinSessionScoped beans.
Stores contextuals in VaadinSession. Other Vaadin CDI contexts are
stored in the corresponding VaadinSessionScoped context.
The context is active when the current VaadinSession is bound to the
calling thread and that thread holds the session lock — i.e. when the code
runs inside an active Vaadin request, a UI#access block, or a
VaadinSession#access block. Code running on a background thread that
has only set VaadinSession.setCurrent(VaadinSession) without
acquiring the session lock is operating outside the supported usage of the
framework; behavior in that case is not guaranteed.
- Since:
- 3.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFor internal use only. -
Constructor Summary
ConstructorsConstructorDescriptionVaadinSessionScopedContext(jakarta.enterprise.inject.spi.BeanManager beanManager) -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddestroy(com.vaadin.flow.server.VaadinSession session) protected ContextualStoragegetContextualStorage(jakarta.enterprise.context.spi.Contextual<?> contextual, boolean createIfNotExist) An implementation has to return the underlying storage which contains the items held in the Context.Class<? extends Annotation>getScope()static booleanGuess whether this context is undeployed.voidinit(jakarta.enterprise.inject.spi.BeanManager beanManager) booleanisActive()Methods inherited from class com.vaadin.cdi.util.AbstractContext
checkActive, destroy, destroyAllActive, destroyAllActive, destroyBean, get, get, getActiveContextualStorages, isPassivatingScope
-
Constructor Details
-
VaadinSessionScopedContext
public VaadinSessionScopedContext(jakarta.enterprise.inject.spi.BeanManager beanManager)
-
-
Method Details
-
init
public void init(jakarta.enterprise.inject.spi.BeanManager beanManager) -
getContextualStorage
protected ContextualStorage getContextualStorage(jakarta.enterprise.context.spi.Contextual<?> contextual, boolean createIfNotExist) Description copied from class:AbstractContextAn implementation has to return the underlying storage which contains the items held in the Context.- Specified by:
getContextualStoragein classAbstractContextcreateIfNotExist- whether a ContextualStorage shall get created if it doesn't yet exist.- Returns:
- the underlying storage
-
getScope
-
isActive
public boolean isActive() -
destroy
public static void destroy(com.vaadin.flow.server.VaadinSession session) -
guessContextIsUndeployed
public static boolean guessContextIsUndeployed()Guess whether this context is undeployed. Tomcat expires sessions after contexts are undeployed. Need this guess to prevent exceptions when try to properly destroy contexts on session expiration.- Returns:
- true when context is not active, but sure it should
-