Questo contenuto non è disponibile nella lingua selezionata.
15.2. Callable and CDI
Where
DistributedCallable
cannot be implemented or is not appropriate, and a reference to input cache used in DistributedExecutorService
is still required, there is an option to inject the input cache by CDI mechanism.
When the
Callable
task arrives at a Red Hat JBoss Data Grid executing node, JBoss Data Grid's CDI mechanism provides an appropriate cache reference, and injects it to the executing Callable
.
To use the JBoss Data Grid CDI with
Callable
:
- Declare a
Cache
field inCallable
and annotate it withorg.infinispan.cdi.Input
- Include the mandatory
@Inject
annotation.
Example 15.2. Using Callable
and the CDI