Package com.avoka.fc.core.util
Class TxnExecutor
- java.lang.Object
-
- com.avoka.fc.core.util.TxnExecutor
-
public class TxnExecutor extends Object
Provides a Cayenne Transaction Executor class, which will execute the specified function in a Cayenne Transaction.- Since:
- 4.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
TxnExecutor.IFunction
Provides a closure function to call in the transaction executor.
-
Constructor Summary
Constructors Constructor Description TxnExecutor(Class callingClass, String errorType)
Create a Transaction Executor object with the given logger.TxnExecutor(Class callingClass, String errorType, int transactionIsolation, boolean readOnly)
Create a Transaction Executor object with the given logger.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
execute(TxnExecutor.IFunction function)
Execute the given function inside a Cayenne transaction.
-
-
-
Constructor Detail
-
TxnExecutor
public TxnExecutor(Class callingClass, String errorType)
Create a Transaction Executor object with the given logger.- Parameters:
callingClass
- the class calling the service, used for error logging purposeserrorType
- the error type to log (required)
-
TxnExecutor
public TxnExecutor(Class callingClass, String errorType, int transactionIsolation, boolean readOnly)
Create a Transaction Executor object with the given logger.- Parameters:
callingClass
- the class calling the service, used for error logging purposeserrorType
- the error type to log (required)transactionIsolation
- the transaction isolation levelreadOnly
- the connection ready only flag- Since:
- 4.3.4
-
-
Method Detail
-
execute
public Object execute(TxnExecutor.IFunction function) throws ApplicationException
Execute the given function inside a Cayenne transaction. If an error occurs that is a RuntimeException, it will be thrown as is; other errors will be wrapped in an ApplicationException.- Parameters:
function
- the function to execute- Returns:
- the function result if successful
- Throws:
ApplicationException
- if an error occurs executing the function or performing a transaction commit
-
-