|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jodd.jtx.JtxTransactionManager
public class JtxTransactionManager
Simple JtxTransaction
manager is responsible for transactions propagation and resource managers.
It also holds various configuration data. It can be considered that all work is done global-wide.
Field Summary | |
---|---|
protected int |
maxResourcesPerTransaction
|
protected boolean |
oneResourceManager
|
protected java.util.Map<java.lang.Class,JtxResourceManager> |
resourceManagers
|
protected java.lang.ThreadLocal<java.util.LinkedList<JtxTransaction>> |
TXSTACK
|
protected boolean |
validateExistingTransaction
|
Constructor Summary | |
---|---|
JtxTransactionManager()
Creates new transaction manager. |
Method Summary | ||
---|---|---|
protected void |
associateTransaction(JtxTransaction tx)
Associate transaction to current thread. |
|
void |
close()
Closes transaction manager. |
|
protected void |
continueTx(JtxTransaction sourceTx,
JtxTransactionMode destMode)
Check if propagation of a transaction is possible, due to source and destination transaction modes. |
|
protected JtxTransaction |
createNewTransaction(JtxTransactionMode tm)
Creates new JtxTransaction instance. |
|
int |
getMaxResourcesPerTransaction()
Returns max number of resources per transaction. |
|
JtxTransaction |
getTransaction()
Returns last transaction associated with current thread or null when thread has no associated transactions created
by this transaction manager. |
|
boolean |
isAssociated(JtxTransaction tx)
Returns true if provided transaction is associated with current thread. |
|
boolean |
isEmpty()
Returns true if no transaction is associated with current thread. |
|
boolean |
isSingleResourceManager()
|
|
boolean |
isValidateExistingTransaction()
Returns whether existing transactions should be validated before participating in them. |
|
protected
|
lookupResourceManager(java.lang.Class<E> resourceType)
Lookups resource manager for provided type. |
|
protected JtxTransaction |
propMandatory(JtxTransactionMode mode)
None -> Error T1 -> T1 (cont.) |
|
protected JtxTransaction |
propNever(JtxTransactionMode mode)
None -> None T1 -> Error |
|
protected JtxTransaction |
propNotSupported(JtxTransactionMode mode)
None -> None T1 -> None |
|
protected JtxTransaction |
propRequired(JtxTransactionMode mode)
None -> T2 T1 -> T1 (cont.) |
|
protected JtxTransaction |
propRequiresNew(JtxTransactionMode mode)
None -> T2 T1 -> T2 |
|
protected JtxTransaction |
propSupports(JtxTransactionMode mode)
None -> None T1 -> T1 (cont.) |
|
void |
registerResourceManager(JtxResourceManager resourceManager)
Registers new resource manager . |
|
protected boolean |
removeTransaction(JtxTransaction tx)
Removes transaction association with current thread. |
|
JtxTransaction |
requestTransaction(JtxTransactionMode mode)
Requests transaction with specified mode . |
|
void |
setMaxResourcesPerTransaction(int maxResourcesPerTransaction)
Sets max number of resources per transaction. |
|
void |
setSingleResourceManager(boolean oneResourceManager)
|
|
void |
setValidateExistingTransaction(boolean validateExistingTransaction)
Sets whether existing transactions should be validated before participating in them. |
|
int |
totalActiveTransactions()
Returns total number of active transactions. |
|
int |
totalTransactions()
Returns total number of transactions associated with current thread. |
|
int |
totalTransactionsWithStatus(JtxStatus status)
Returns total number of transactions of the specified status associated with current thread. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int maxResourcesPerTransaction
protected boolean oneResourceManager
protected boolean validateExistingTransaction
protected java.util.Map<java.lang.Class,JtxResourceManager> resourceManagers
protected final java.lang.ThreadLocal<java.util.LinkedList<JtxTransaction>> TXSTACK
Constructor Detail |
---|
public JtxTransactionManager()
Method Detail |
---|
public int getMaxResourcesPerTransaction()
public void setMaxResourcesPerTransaction(int maxResourcesPerTransaction)
public boolean isValidateExistingTransaction()
public void setValidateExistingTransaction(boolean validateExistingTransaction)
When participating in an existing transaction (e.g. with PROPAGATION_REQUIRES or PROPAGATION_SUPPORTS encountering an existing transaction), this outer transaction's characteristics will apply even to the inner transaction scope. Validation will detect incompatible isolation level and read-only settings on the inner transaction definition and reject participation accordingly through throwing a corresponding exception.
public boolean isSingleResourceManager()
public void setSingleResourceManager(boolean oneResourceManager)
public boolean isEmpty()
true
if no transaction is associated with current thread.
public int totalTransactions()
public int totalTransactionsWithStatus(JtxStatus status)
public int totalActiveTransactions()
public boolean isAssociated(JtxTransaction tx)
true
if provided transaction is associated with current thread.
protected boolean removeTransaction(JtxTransaction tx)
public JtxTransaction getTransaction()
null
when thread has no associated transactions created
by this transaction manager.
protected void associateTransaction(JtxTransaction tx)
protected JtxTransaction createNewTransaction(JtxTransactionMode tm)
JtxTransaction
instance.
Custom implementations of manager may override this method for
creating custom transaction instances.
public JtxTransaction requestTransaction(JtxTransactionMode mode)
mode
.
Depending on propagation behavior, it will return either existing or new transaction;
or the exception may be thrown indicating propagation mismatch.
protected void continueTx(JtxTransaction sourceTx, JtxTransactionMode destMode)
setValidateExistingTransaction(boolean)
protected JtxTransaction propRequired(JtxTransactionMode mode)
None -> T2 T1 -> T1 (cont.)
protected JtxTransaction propRequiresNew(JtxTransactionMode mode)
None -> T2 T1 -> T2
protected JtxTransaction propSupports(JtxTransactionMode mode)
None -> None T1 -> T1 (cont.)
protected JtxTransaction propMandatory(JtxTransactionMode mode)
None -> Error T1 -> T1 (cont.)
protected JtxTransaction propNotSupported(JtxTransactionMode mode)
None -> None T1 -> None
protected JtxTransaction propNever(JtxTransactionMode mode)
None -> None T1 -> Error
public void registerResourceManager(JtxResourceManager resourceManager)
resource manager
.
protected <E> JtxResourceManager<E> lookupResourceManager(java.lang.Class<E> resourceType)
public void close()
JtxResourceManager
will be closed.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |