Enum RunOptions.Semantic
- java.lang.Object
-
- java.lang.Enum<RunOptions.Semantic>
-
- io.quarkus.narayana.jta.RunOptions.Semantic
-
- All Implemented Interfaces:
Serializable,Comparable<RunOptions.Semantic>
- Enclosing class:
- RunOptions
public static enum RunOptions.Semantic extends Enum<RunOptions.Semantic>
Enum that can be used to control the transaction behaviour in the presence or absence of an existing transaction.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description DISALLOW_EXISTINGIf a transaction is already associated with the current thread aQuarkusTransactionExceptionwill be thrown, otherwise a new transaction is started, and follows all the normal lifecycle rules.JOIN_EXISTINGIf no transaction is active then a new transaction will be started, and committed when the method ends.REQUIRE_NEWThis is the default semantic.SUSPEND_EXISTINGIf no transaction is active then this semantic is basically a no-op.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static RunOptions.SemanticvalueOf(String name)Returns the enum constant of this type with the specified name.static RunOptions.Semantic[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
DISALLOW_EXISTING
public static final RunOptions.Semantic DISALLOW_EXISTING
If a transaction is already associated with the current thread aQuarkusTransactionExceptionwill be thrown, otherwise a new transaction is started, and follows all the normal lifecycle rules.
-
JOIN_EXISTING
public static final RunOptions.Semantic JOIN_EXISTING
If no transaction is active then a new transaction will be started, and committed when the method ends. If an exception is thrown the exception handler registered by
RunOptions.exceptionHandler(Function)will be called to decide if the TX should be committed or rolled back.If an existing transaction is active then the method is run in the context of the existing transaction. If an exception is thrown the exception handler will be called, however a result of
RunOptions.ExceptionResult.ROLLBACKwill result in the TX marked as rollback only, while a result ofRunOptions.ExceptionResult.COMMITwill result in no action being taken.
-
REQUIRE_NEW
public static final RunOptions.Semantic REQUIRE_NEW
This is the default semantic.If an existing transaction is already associated with the current thread then the transaction is suspended, and resumed once the current transaction is complete.
A new transaction is started after the existing transaction is suspended, and follows all the normal lifecycle rules.
-
SUSPEND_EXISTING
public static final RunOptions.Semantic SUSPEND_EXISTING
If no transaction is active then this semantic is basically a no-op.If a transaction is active then it is suspended, and resumed after the task is run.
The exception handler will never be consulted when this semantic is in use, specifying both an exception handler and this semantic is considered an error.
This semantic allows for code to easily be run outside the scope of a transaction.
-
-
Method Detail
-
values
public static RunOptions.Semantic[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (RunOptions.Semantic c : RunOptions.Semantic.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static RunOptions.Semantic valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
-