Class Jta
- All Implemented Interfaces:
JtaTransactionLookup
var jta = Jta.builder(applicationOwnedTransactionManager).timeout(Duration.ofSeconds(5)).build();
app.use(jta.transaction());
The application supplies its own jakarta.transaction.TransactionManager as an Object; it is checked when the builder is created and adapted inside this module. No JTA type
appears in an Axiom signature, and no transaction manager is bundled or published here. Nothing
is bound until transaction() is registered as middleware.
Each boundary suspends any transaction already associated with the thread, begins a new one for the request, and commits when the chain returns a non-problem response or rolls back when it throws, answers a problem status or sets rollback-only. Completion always restores the previously associated transaction, including when nested boundaries run on the same request. Failures become fixed-code problem responses with no provider message or class name; their cause stays available to the framework's logs. Instances are immutable and thread-safe after construction.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classConfigures an immutableJta; not thread-safe, build once at startup. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReports whether a transaction is currently associated with the request represented bycontext.static Jta.BuilderStarts a configuration around the application's transaction manager.static Optional<TransactionContext> Finds the request's transaction context, available to a handler while a boundary runs and to an error handler just after it ends.booleanrollbackOnly(Object context) Reports whether the request's active transaction has been marked rollback-only.Returns the request's transaction status as a plain name:ACTIVE,MARKED_ROLLBACK,COMMITTED,ROLLED_BACK,INACTIVEorUNKNOWN.Returns the middleware that binds one transaction around each request that runs through it.
-
Method Details
-
builder
Starts a configuration around the application's transaction manager. A value that is not a JTATransactionManageris rejected here, with an exception naming the expected type but not the supplied object.- Parameters:
transactionManager- application-owned transaction manager, supplied as anObject- Returns:
- a builder
- Throws:
IllegalArgumentException- if the value is not a JTA transaction manager
-
transaction
Returns the middleware that binds one transaction around each request that runs through it. The same thread-safe instance may be registered globally or on one route, and more than once to create nested, independent scopes.- Returns:
- transaction-boundary middleware
-
context
Finds the request's transaction context, available to a handler while a boundary runs and to an error handler just after it ends. The lookup uses the request's context object, not a thread local, so a later request on the same thread cannot see this one's transaction.- Parameters:
context- the request's Axiom context- Returns:
- the transaction context, if a boundary ran for this request
- Throws:
NullPointerException- if the context is null
-
active
Description copied from interface:JtaTransactionLookupReports whether a transaction is currently associated with the request represented bycontext.- Specified by:
activein interfaceJtaTransactionLookup- Parameters:
context- the request's Axiom context, or any object to answerfalse- Returns:
- true while a transaction is active for that request
-
status
Description copied from interface:JtaTransactionLookupReturns the request's transaction status as a plain name:ACTIVE,MARKED_ROLLBACK,COMMITTED,ROLLED_BACK,INACTIVEorUNKNOWN.- Specified by:
statusin interfaceJtaTransactionLookup- Parameters:
context- the request's Axiom context- Returns:
- one of the six status names
-
rollbackOnly
Description copied from interface:JtaTransactionLookupReports whether the request's active transaction has been marked rollback-only.- Specified by:
rollbackOnlyin interfaceJtaTransactionLookup- Parameters:
context- the request's Axiom context- Returns:
- true when rollback-only was set by the handler or the provider
-