Package com.jsgalactic.axiom.jta
Class Jta.Builder
java.lang.Object
com.jsgalactic.axiom.jta.Jta.Builder
- Enclosing class:
Jta
Configures an immutable
Jta; not thread-safe, build once at startup.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the immutable adapter.commitWhen(Predicate<Throwable> predicate) Adds a predicate-based commit rule; a later matching rule wins, as withnoRollbackOn(Class).noRollbackOn(Class<? extends Throwable> type) Adds a rule that commits when the chain throws a throwable of this type.problemStatus(TransactionFailure failure, int status) Overrides the problem status for one kind of transaction-boundary failure.rollbackOn(Class<? extends Throwable> type) Adds a rule that rolls back when the chain throws a throwable of this type.rollbackWhen(Predicate<Throwable> predicate) Adds a predicate-based rollback rule; a later matching rule wins, as withrollbackOn(Class).Sets the transaction timeout.
-
Method Details
-
timeout
Sets the transaction timeout. JTA expresses it in whole seconds, so a sub-second value is rounded up and a value under one second still asks for one second. The default leaves the provider's own timeout alone.- Parameters:
timeout- positive duration of at most one day- Returns:
- this builder
- Throws:
IllegalArgumentException- for an invalid duration
-
rollbackOn
Adds a rule that rolls back when the chain throws a throwable of this type. Rules run in the order they were added and a later matching rule wins over an earlier one. The built-in rule rolls back on every throwable and stays in force when no added rule matches.- Parameters:
type- throwable type to match, including subclasses- Returns:
- this builder
-
noRollbackOn
Adds a rule that commits when the chain throws a throwable of this type. The exception still propagates; this rule is for failures an application error handler maps to a successful answer, and has no effect on a problem response returned by the chain itself.- Parameters:
type- throwable type to match, including subclasses- Returns:
- this builder
-
rollbackWhen
Adds a predicate-based rollback rule; a later matching rule wins, as withrollbackOn(Class).- Parameters:
predicate- thread-safe test on the throwable leaving the chain- Returns:
- this builder
-
commitWhen
Adds a predicate-based commit rule; a later matching rule wins, as withnoRollbackOn(Class).- Parameters:
predicate- thread-safe test on the throwable leaving the chain- Returns:
- this builder
-
problemStatus
Overrides the problem status for one kind of transaction-boundary failure. Only 409, 503 and 500 are accepted, and every mapped response uses a fixed code from that status.- Parameters:
failure- the boundary operation to mapstatus- 409, 503 or 500- Returns:
- this builder
- Throws:
IllegalArgumentException- for another status
-
build
Builds the immutable adapter. It starts no transaction and registers no route.- Returns:
- a thread-safe transaction boundary
-