|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjodd.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 int |
totalTransactions
|
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. |
|
protected boolean |
checkValidTxContext(JtxTransaction currentTx,
java.lang.Object destContext)
Returns true if context is specified and it is different then of existing transaction. |
|
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,
java.lang.Object context)
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 |
isAssociatedWithThread(JtxTransaction tx)
Returns true if provided transaction
is associated with current thread. |
|
boolean |
isSingleResourceManager()
Returns true if this transaction manager works with just one resource. |
|
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(JtxTransaction currentTx,
JtxTransactionMode mode,
java.lang.Object context)
Propagation: MANDATORY None -> Error T1 -> T1 (cont.) |
|
protected JtxTransaction |
propNever(JtxTransaction currentTx,
JtxTransactionMode mode,
java.lang.Object context)
Propagation: NEVER None -> None T1 -> Error |
|
protected JtxTransaction |
propNotSupported(JtxTransaction currentTx,
JtxTransactionMode mode,
java.lang.Object context)
Propagation: NOT_SUPPORTED None -> None T1 -> None |
|
protected JtxTransaction |
propRequired(JtxTransaction currentTx,
JtxTransactionMode mode,
java.lang.Object context)
Propagation: REQUIRED None -> T2 T1 -> T1 (cont.) |
|
protected JtxTransaction |
propRequiresNew(JtxTransaction currentTx,
JtxTransactionMode mode,
java.lang.Object context)
Propagation: REQUIRES_NEW None -> T2 T1 -> T2 |
|
protected JtxTransaction |
propSupports(JtxTransaction currentTx,
JtxTransactionMode mode,
java.lang.Object context)
Propagation: SUPPORTS 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)
|
|
JtxTransaction |
requestTransaction(JtxTransactionMode mode,
java.lang.Object context)
Requests transaction with specified mode. |
|
void |
setMaxResourcesPerTransaction(int maxResourcesPerTransaction)
Sets max number of resources per transaction. |
|
void |
setSingleResourceManager(boolean oneResourceManager)
Specifies if transaction manager works with just one resource. |
|
void |
setValidateExistingTransaction(boolean validateExistingTransaction)
Sets whether existing transactions should be validated before participating in them. |
|
int |
totalActiveThreadTransactions()
Returns total number of active transactions associated with current thread. |
|
int |
totalThreadTransactions()
Returns total number of transactions associated with current thread. |
|
int |
totalThreadTransactionsWithStatus(JtxStatus status)
Returns total number of transactions of the specified status associated with current thread. |
|
int |
totalTransactions()
Returns total number of transactions issued by this transaction manager. |
|
| 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
protected int totalTransactions
| 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()
true if this transaction manager works with just one resource.
public void setSingleResourceManager(boolean oneResourceManager)
public int totalThreadTransactions()
public int totalThreadTransactionsWithStatus(JtxStatus status)
public int totalActiveThreadTransactions()
public boolean isAssociatedWithThread(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)
public int totalTransactions()
protected JtxTransaction createNewTransaction(JtxTransactionMode tm,
java.lang.Object context)
JtxTransaction instance.
Custom implementations of manager may override this method for
creating custom transaction instances.
public JtxTransaction requestTransaction(JtxTransactionMode mode)
public JtxTransaction requestTransaction(JtxTransactionMode mode,
java.lang.Object context)
mode.
Depending on propagation behavior, it will return either existing or new transaction.
The exception may be thrown indicating propagation mismatch.
protected boolean checkValidTxContext(JtxTransaction currentTx,
java.lang.Object destContext)
true if context is specified and it is different then of existing transaction.
protected void continueTx(JtxTransaction sourceTx,
JtxTransactionMode destMode)
setValidateExistingTransaction(boolean)
protected JtxTransaction propRequired(JtxTransaction currentTx,
JtxTransactionMode mode,
java.lang.Object context)
None -> T2 T1 -> T1 (cont.)
protected JtxTransaction propRequiresNew(JtxTransaction currentTx,
JtxTransactionMode mode,
java.lang.Object context)
None -> T2 T1 -> T2
protected JtxTransaction propSupports(JtxTransaction currentTx,
JtxTransactionMode mode,
java.lang.Object context)
None -> None T1 -> T1 (cont.)
protected JtxTransaction propMandatory(JtxTransaction currentTx,
JtxTransactionMode mode,
java.lang.Object context)
None -> Error T1 -> T1 (cont.)
protected JtxTransaction propNotSupported(JtxTransaction currentTx,
JtxTransactionMode mode,
java.lang.Object context)
None -> None T1 -> None
protected JtxTransaction propNever(JtxTransaction currentTx,
JtxTransactionMode mode,
java.lang.Object context)
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 | ||||||||