@Qualifier @Retention(value=RUNTIME) @Target(value={FIELD,METHOD,TYPE,PARAMETER}) public @interface NamedInstance
This annotation is used to achieve out of the box ManagedExecutor and ThreadContext instance
sharing through CDI injection.
Qualifies a CDI injection point for a ManagedExecutor or ThreadContext with a unique name
across the application.
This annotation can be used in combination with the ManagedExecutorConfig or
ThreadContextConfig annotation to define a new instance. For example,
@Inject @NamedInstance("myExecutor") @ManagedExecutorConfig(maxAsync=10)
ManagedExecutor myExecutor;
@Inject @NamedInstance("myContext") @ThreadContextConfig(propagated = { ThreadContext.SECURITY, ThreadContext.CDI })
ThreadContext myThreadContext;
Once used as shown above, this annotation can be used on its own to qualify an injection point with the name of
an existing instance. Injection points with the same value() then share the same
underlying contextual instance. For example, referencing a name from the previous example,
@Inject @NamedInstance("myExecutor")
ManagedExecutor exec1;
@Inject @NamedInstance("myContext")
ThreadContext myContextPropagator;
Alternatively, an application can use this annotation as a normal CDI qualifier, defining its own scope, producer, and disposer. For example,
public abstract String value
ManagedExecutor or ThreadContext.Copyright © 2018–2020. All rights reserved.