Package org.cyclos.impl
Interface InvokerHandler
-
public interface InvokerHandlerHandler used to control the invocation of callbacks with a givenSessionData, which can also be combined with transactions
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description ScheduledExecutorServicegetExecutorService()Returns theScheduledExecutorServicewhich can be used for running tasks in parallel.<T> TrunAs(SessionData sessionData, Callable<T> callable)Runs the givenCallableusing the givenSessionData, within the caller's transaction<T> TrunAsInCurrentOrNewTransaction(SessionData sessionData, TransactionLevel level, TransactionCallback<T> callback)If there is a transaction in the current thread with a compatible transaction level as the given one, runs the given transaction callback in the current transaction.<T> Future<T>runAsInParallelTransaction(SessionData sessionData, TransactionLevel transactionLevel, TransactionCallback<T> callback)Deprecated.Clients shouldn't await for the result by calling Future.get.<T> TrunAsInTransaction(SessionData sessionData, TransactionLevel transactionLevel, TransactionCallback<T> callback)Runs the givenTransactionCallbackin a transaction in the current thread, with the givenTransactionLevel, within the context of the givenSessionDatavoidsubmitAsInParallelTransaction(SessionData sessionData, TransactionLevel transactionLevel, Consumer<TransactionStatus> callback)Submits a new transaction to be executed in a new thread, with the givenTransactionLevel, within the context of the givenSessionData.ThrowabletranslateException(Throwable t)Translate known exceptions into Cyclos' own exceptions
-
-
-
Method Detail
-
getExecutorService
ScheduledExecutorService getExecutorService()
Returns theScheduledExecutorServicewhich can be used for running tasks in parallel. One example which uses thisScheduledExecutorServiceisrunAsInParallelTransaction(SessionData, TransactionLevel, TransactionCallback).
-
runAs
<T> T runAs(SessionData sessionData, Callable<T> callable)
Runs the givenCallableusing the givenSessionData, within the caller's transaction
-
runAsInCurrentOrNewTransaction
<T> T runAsInCurrentOrNewTransaction(SessionData sessionData, TransactionLevel level, TransactionCallback<T> callback) throws RetryException
If there is a transaction in the current thread with a compatible transaction level as the given one, runs the given transaction callback in the current transaction. Otherwise, throws aRetryExceptionto force a new transaction with the given level to be created, so the next time it will be compatible- Throws:
RetryException- If the current transaction level is not compatible with the given one
-
runAsInParallelTransaction
@Deprecated <T> Future<T> runAsInParallelTransaction(SessionData sessionData, TransactionLevel transactionLevel, TransactionCallback<T> callback)
Deprecated.Clients shouldn't await for the result by calling Future.get. UsesubmitAsInParallelTransaction(SessionData, TransactionLevel, Consumer)instead. For scripts, use custom background tasks instead, because runAsInParallelTransaction may commit while the main transaction rolls-back, which would probably make the system inconsistent. With custom background tasks, if the main transaction rolls back, so will all the scheduled background task executions be rolled-back.Submits a new transaction to be executed in a new thread, with the givenTransactionLevel, within the context of the givenSessionData
-
runAsInTransaction
<T> T runAsInTransaction(SessionData sessionData, TransactionLevel transactionLevel, TransactionCallback<T> callback)
Runs the givenTransactionCallbackin a transaction in the current thread, with the givenTransactionLevel, within the context of the givenSessionData
-
submitAsInParallelTransaction
void submitAsInParallelTransaction(SessionData sessionData, TransactionLevel transactionLevel, Consumer<TransactionStatus> callback)
Submits a new transaction to be executed in a new thread, with the givenTransactionLevel, within the context of the givenSessionData. For scripts, use custom background tasks instead, because submitAsInParallelTransaction may commit while the main transaction rolls-back, which would probably make the system inconsistent. With custom background tasks, if the main transaction rolls back, so will all the scheduled background task executions be rolled-back.
-
-