Annotation Type NamedInstance
-
@Qualifier @Retention(RUNTIME) @Target({FIELD,METHOD,TYPE,PARAMETER}) public @interface NamedInstance
This annotation is used to achieve out of the box
ManagedExecutorandThreadContextinstance sharing through CDI injection.Qualifies a CDI injection point for a
ManagedExecutororThreadContextwith a unique name across the application.This annotation can be used in combination with the
ManagedExecutorConfigorThreadContextConfigannotation 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,
- Author:
- Matej Novotny
-
-
Element Detail
-
value
String value
Unique name that qualifies aManagedExecutororThreadContext.- Returns:
- the name that qualifies a
ManagedExecutororThreadContext.
-
-