Package com.yworkflow
Interface WorkflowTransaction
public interface WorkflowTransaction
Provides transactional support for workflow operations. The WorkflowTransaction interface allows
workflow operations to be executed within a transaction context, ensuring atomicity and
consistency.
Transactions ensure that either all operations within the transaction succeed, or all operations are rolled back if any operation fails. This is particularly important for workflow operations that involve multiple state changes or external system interactions.
The interface supports both operations that return a value and operations that return void. All operations are executed within the same transaction context.
- Since:
- 1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescription<R,T extends Throwable>
Rexecute(WorkflowTransactionalOperation<R, T> operation) Executes a transactional operation that returns a value.<T extends Throwable>
voidexecute(WorkflowTransactionalVoidOperation<T> operation) Executes a transactional operation that returns void.static WorkflowTransactionnoOp()
-
Method Details
-
execute
Executes a transactional operation that returns a value. The operation is executed within a transaction context, and the transaction is committed if the operation completes successfully, or rolled back if an exception is thrown.- Type Parameters:
R- the return type of the operationT- the type of exception that can be thrown- Parameters:
operation- the operation to execute- Returns:
- the result of the operation
- Throws:
T- if the operation throws an exception
-
execute
Executes a transactional operation that returns void. The operation is executed within a transaction context, and the transaction is committed if the operation completes successfully, or rolled back if an exception is thrown.- Type Parameters:
T- the type of exception that can be thrown- Parameters:
operation- the operation to execute- Throws:
T- if the operation throws an exception
-
noOp
- Returns:
- a noop WorkflowTransaction that simply execute the passed operations
-