Package io.quarkus.arc.impl
Class CurrentManagedContext
java.lang.Object
io.quarkus.arc.impl.CurrentManagedContext
- All Implemented Interfaces:
InjectableContext,ManagedContext,jakarta.enterprise.context.spi.AlterableContext,jakarta.enterprise.context.spi.Context
- Direct Known Subclasses:
SessionContext
A managed context backed by the
CurrentContext.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface io.quarkus.arc.InjectableContext
InjectableContext.ContextState -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCurrentManagedContext(CurrentContext<CurrentManagedContext.CurrentContextState> currentContext, Supplier<ContextInstances> contextInstances, Consumer<Object> initializedNotifier, Consumer<Object> beforeDestroyedNotifier, Consumer<Object> destroyedNotifier) -
Method Summary
Modifier and TypeMethodDescriptionactivate(InjectableContext.ContextState initialState) Activate the context.voidDeactivate the context - do not destroy existing contextual instances.voiddestroy()Destroys the current context and all existing contextual instances.voidDestroy all contextual instances from the given state.voiddestroy(jakarta.enterprise.context.spi.Contextual<?> contextual) <T> Tget(jakarta.enterprise.context.spi.Contextual<T> contextual) <T> Tget(jakarta.enterprise.context.spi.Contextual<T> contextual, jakarta.enterprise.context.spi.CreationalContext<T> creationalContext) <T> TgetIfActive(jakarta.enterprise.context.spi.Contextual<T> contextual, Function<jakarta.enterprise.context.spi.Contextual<T>, jakarta.enterprise.context.spi.CreationalContext<T>> creationalContextFun) If the context is active then return an existing instance of certain contextual type or create a new instance, otherwise return a null value.getState()Creates a newInjectableContext.ContextState.booleanisActive()protected abstract jakarta.enterprise.context.ContextNotActiveExceptionprotected voidtraceActivate(InjectableContext.ContextState initialState) protected voidprotected voidprotected org.jboss.logging.LoggertraceLog()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.enterprise.context.spi.Context
getScopeMethods inherited from interface io.quarkus.arc.InjectableContext
getStateIfActive, isNormalMethods inherited from interface io.quarkus.arc.ManagedContext
activate, activate$$bridge, activate$$bridge, terminate
-
Constructor Details
-
CurrentManagedContext
protected CurrentManagedContext(CurrentContext<CurrentManagedContext.CurrentContextState> currentContext, Supplier<ContextInstances> contextInstances, Consumer<Object> initializedNotifier, Consumer<Object> beforeDestroyedNotifier, Consumer<Object> destroyedNotifier)
-
-
Method Details
-
getState
- Specified by:
getStatein interfaceInjectableContext- Returns:
- the current state
-
activate
Description copied from interface:ManagedContextActivate the context.If invoked with
nullparameter, a freshInjectableContext.ContextStateis automatically created.- Specified by:
activatein interfaceManagedContext- Parameters:
initialState- The initial state, may benull- Returns:
- the context state
-
deactivate
public void deactivate()Description copied from interface:ManagedContextDeactivate the context - do not destroy existing contextual instances.- Specified by:
deactivatein interfaceManagedContext
-
getIfActive
public <T> T getIfActive(jakarta.enterprise.context.spi.Contextual<T> contextual, Function<jakarta.enterprise.context.spi.Contextual<T>, jakarta.enterprise.context.spi.CreationalContext<T>> creationalContextFun) Description copied from interface:InjectableContextIf the context is active then return an existing instance of certain contextual type or create a new instance, otherwise return a null value. This allows for theContext.isActive()check and the actual creation to happen in a single method, which gives a performance benefit by performing fewer thread local operations.- Specified by:
getIfActivein interfaceInjectableContext- Type Parameters:
T- the type of contextual type- Parameters:
contextual- the contextual typecreationalContextFun- the creational context function- Returns:
- the contextual instance, or a null value
-
get
public <T> T get(jakarta.enterprise.context.spi.Contextual<T> contextual, jakarta.enterprise.context.spi.CreationalContext<T> creationalContext) - Specified by:
getin interfacejakarta.enterprise.context.spi.Context
-
get
public <T> T get(jakarta.enterprise.context.spi.Contextual<T> contextual) - Specified by:
getin interfacejakarta.enterprise.context.spi.Context
-
isActive
public boolean isActive()- Specified by:
isActivein interfacejakarta.enterprise.context.spi.Context
-
destroy
public void destroy()Description copied from interface:InjectableContextDestroys the current context and all existing contextual instances.- Specified by:
destroyin interfaceInjectableContext
-
destroy
public void destroy(jakarta.enterprise.context.spi.Contextual<?> contextual) - Specified by:
destroyin interfacejakarta.enterprise.context.spi.AlterableContext
-
destroy
Description copied from interface:InjectableContextDestroy all contextual instances from the given state.The default implementation is not optimized and does not guarantee proper sychronization. Implementations of this interface are encouraged to provide an optimized implementation of this method.
- Specified by:
destroyin interfaceInjectableContext- Parameters:
state-
-
initializeState
Description copied from interface:ManagedContextCreates a newInjectableContext.ContextState.Creating a context state does not fire
@Initializedevent for given context.- Specified by:
initializeStatein interfaceManagedContext- Returns:
- a new initialized context state
-
traceLog
protected org.jboss.logging.Logger traceLog() -
traceActivate
-
traceDeactivate
protected void traceDeactivate() -
traceDestroy
-
notActive
protected abstract jakarta.enterprise.context.ContextNotActiveException notActive()
-