String
value. Let's create one such class:JtxResourceManager
for our resource. The main method to implement is beginTransaction()
. It starts a transaction on our resource depending on transaction mode.JtxTransactionManager
, propagation behavior and timeout will be already supported! Therefore, our resource manager has only to deal with isolation and read-only attribute. We will ignore isolation to make things simpler. Here is how resource manager may look like:beginTransaction()
\: the active
flag tells us if real transaction should be started or we are working in auto-commit mode. When it is set, we create a transaction-aware resource. Since isolation is ignored, we only need to pass read-only flag.LeanJtxWorker
, a class that utilizes JtxTransactionManager
and makes it more convenient for use when transaction is requested over different context, i.e. with transaction nesting. Basically, everything stays the same, except LeanJtxWorker
would return null
when new transaction is not created on its request, meaning that current transaction matches the requested transaction attributes (mostly propagation).