Package org.infinispan.cache.impl
Class InvocationHelper
- java.lang.Object
-
- org.infinispan.cache.impl.InvocationHelper
-
- All Implemented Interfaces:
TransactionResourceConverter
public class InvocationHelper extends Object implements TransactionResourceConverter
It invokes theVisitableCommand
through this cacheAsyncInterceptorChain
.It creates injected transactions and auto commits them, if the cache is transactional.
- Since:
- 11.0
- Author:
- Pedro Ruivo
-
-
Field Summary
Fields Modifier and Type Field Description protected BatchContainer
batchContainer
protected BlockingManager
blockingManager
protected Configuration
config
protected InvocationContextFactory
invocationContextFactory
protected AsyncInterceptorChain
invoker
protected javax.transaction.TransactionManager
transactionManager
-
Constructor Summary
Constructors Constructor Description InvocationHelper()
-
Method Summary
-
-
-
Field Detail
-
invoker
protected AsyncInterceptorChain invoker
-
invocationContextFactory
protected InvocationContextFactory invocationContextFactory
-
transactionManager
protected javax.transaction.TransactionManager transactionManager
-
config
protected Configuration config
-
batchContainer
protected BatchContainer batchContainer
-
blockingManager
protected BlockingManager blockingManager
-
-
Method Detail
-
invoke
public <T> T invoke(VisitableCommand command, int keyCount)
Same asinvoke(ContextBuilder, VisitableCommand, int)
but using the defaultContextBuilder
.- Type Parameters:
T
- The return type.- Parameters:
command
- TheVisitableCommand
to invoke.keyCount
- The number of keys affected by thecommand
.- Returns:
- The invocation result.
-
invoke
public <T> T invoke(ContextBuilder builder, VisitableCommand command, int keyCount)
Same asinvoke(InvocationContext, VisitableCommand)
but usingbuilder
to build theInvocationContext
to use.- Type Parameters:
T
- The return type.- Parameters:
builder
- TheContextBuilder
to create theInvocationContext
to use.command
- TheVisitableCommand
to invoke.keyCount
- The number of keys affected by thecommand
.- Returns:
- The invocation result.
-
invoke
public <T> T invoke(InvocationContext context, VisitableCommand command)
Invokes thecommand
usingcontext
.This method blocks until the
command
finishes. UseinvokeAsync(InvocationContext, VisitableCommand)
for non-blocking.- Type Parameters:
T
- The return type.- Parameters:
context
- TheInvocationContext
to use.command
- TheVisitableCommand
to invoke.- Returns:
- The invocation result.
-
invokeAsync
public <T> CompletableFuture<T> invokeAsync(VisitableCommand command, int keyCount)
Same asinvoke(ContextBuilder, VisitableCommand, int)
but using the defaultContextBuilder
.- Type Parameters:
T
- The return type.- Parameters:
command
- TheVisitableCommand
to invoke.keyCount
- The number of keys affected by thecommand
.- Returns:
- A
CompletableFuture
with the result.
-
invokeAsync
public <T> CompletableFuture<T> invokeAsync(ContextBuilder builder, VisitableCommand command, int keyCount)
Same asinvoke(InvocationContext, VisitableCommand)
but using theInvocationContext
created bybuilder
.- Type Parameters:
T
- The return type.- Parameters:
builder
- TheContextBuilder
to create theInvocationContext
to use.command
- TheVisitableCommand
to invoke.keyCount
- The number of keys affected by thecommand
.- Returns:
- A
CompletableFuture
with the result.
-
invokeAsync
public <T> CompletableFuture<T> invokeAsync(InvocationContext context, VisitableCommand command)
Invokes thecommand
usingcontext
and returns aCompletableFuture
.The
CompletableFuture
is completed with the return value of the invocation.- Type Parameters:
T
- The return type.- Parameters:
context
- TheInvocationContext
to use.command
- TheVisitableCommand
to invoke.- Returns:
- A
CompletableFuture
with the result.
-
createInvocationContextWithImplicitTransaction
public InvocationContext createInvocationContextWithImplicitTransaction(int keyCount, boolean forceCreateTransaction)
Creates an invocation context with an implicit transaction if it is required. An implicit transaction is created if there is no current transaction and autoCommit is enabled.- Parameters:
keyCount
- how many keys are expected to be changed- Returns:
- the invocation context
-
convertSynchronization
public AsyncSynchronization convertSynchronization(javax.transaction.Synchronization synchronization)
- Specified by:
convertSynchronization
in interfaceTransactionResourceConverter
- Parameters:
synchronization
- TheSynchronization
to convert.- Returns:
- An
AsyncSynchronization
instance ofsynchronization
.
-
convertXaResource
public AsyncXaResource convertXaResource(XAResource resource)
- Specified by:
convertXaResource
in interfaceTransactionResourceConverter
- Parameters:
resource
- TheXAResource
to convert.- Returns:
- An
AsyncXaResource
instance ofresource
.
-
-