io.quarkus.narayana.jta.RunOptionsBase Maven / Gradle / Ivy
Show all versions of quarkus-narayana-jta Show documentation
package io.quarkus.narayana.jta;
import java.util.function.Function;
/**
* An abstract base for both {@link RunOptions} and {@link TransactionRunnerImpl}.
*
* Necessary because having {@link RunOptions} extend {@link TransactionRunnerImpl}.,
* or the other way around, results in signature conflicts in {@code exceptionHandler(Function)}.
*/
class RunOptionsBase {
TransactionSemantics semantics = TransactionSemantics.REQUIRE_NEW;
int timeout = 0;
Function exceptionHandler;
RunOptionsBase setTimeout(int seconds) {
if (seconds < 0) {
throw new IllegalArgumentException("seconds cannot be negative");
}
this.timeout = seconds;
return this;
}
RunOptionsBase setSemantics(TransactionSemantics semantics) {
this.semantics = semantics;
return this;
}
RunOptionsBase setExceptionHandler(Function handler) {
this.exceptionHandler = handler;
return this;
}
}