Package net.sf.ehcache
Class TransactionController
- java.lang.Object
-
- net.sf.ehcache.TransactionController
-
public final class TransactionController extends java.lang.ObjectTransactionController is used to begin, commit and rollback local transactions- Author:
- Ludovic Orban
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbegin()Begin a new transaction and bind its context to the current threadvoidbegin(int transactionTimeoutSeconds)Begin a new transaction with the specified timeout and bind its context to the current threadvoidcommit()Commit the transaction bound to the current threadvoidcommit(boolean ignoreTimeout)Commit the transaction bound to the current thread, ignoring if the transaction timed outLocalTransactionContextgetCurrentTransactionContext()Get the transaction context bond to the current threadintgetDefaultTransactionTimeout()Get the default transaction timeout in secondsLocalRecoveryManagergetRecoveryManager()Get the local transactions recovery manager of this cache managerlonggetTransactionCommittedCount()Get the committed transactions countlonggetTransactionRolledBackCount()Get the rolled back transactions countlonggetTransactionTimedOutCount()Get the timed out transactions count.voidrollback()Rollback the transaction bound to the current threadvoidsetDefaultTransactionTimeout(int defaultTransactionTimeoutSeconds)Set the default transaction timeout in seconds, it must be > 0voidsetRollbackOnly()Mark the transaction bound to the current thread for rollback only
-
-
-
Method Detail
-
getDefaultTransactionTimeout
public int getDefaultTransactionTimeout()
Get the default transaction timeout in seconds- Returns:
- the default transaction timeout
-
setDefaultTransactionTimeout
public void setDefaultTransactionTimeout(int defaultTransactionTimeoutSeconds)
Set the default transaction timeout in seconds, it must be > 0- Parameters:
defaultTransactionTimeoutSeconds- the default transaction timeout
-
begin
public void begin()
Begin a new transaction and bind its context to the current thread
-
begin
public void begin(int transactionTimeoutSeconds)
Begin a new transaction with the specified timeout and bind its context to the current thread- Parameters:
transactionTimeoutSeconds- the timeout foe this transaction in seconds
-
commit
public void commit()
Commit the transaction bound to the current thread
-
commit
public void commit(boolean ignoreTimeout)
Commit the transaction bound to the current thread, ignoring if the transaction timed out- Parameters:
ignoreTimeout- true if the transaction should be committed no matter if it timed out or not
-
rollback
public void rollback()
Rollback the transaction bound to the current thread
-
setRollbackOnly
public void setRollbackOnly()
Mark the transaction bound to the current thread for rollback only
-
getCurrentTransactionContext
public LocalTransactionContext getCurrentTransactionContext()
Get the transaction context bond to the current thread- Returns:
- the transaction context bond to the current thread or null if no transaction started on the current thread
-
getTransactionCommittedCount
public long getTransactionCommittedCount()
Get the committed transactions count- Returns:
- the committed transactions count
-
getTransactionRolledBackCount
public long getTransactionRolledBackCount()
Get the rolled back transactions count- Returns:
- the rolled back transactions count
-
getTransactionTimedOutCount
public long getTransactionTimedOutCount()
Get the timed out transactions count. Note that only transactions which failed to commit due to a timeout are taken into account- Returns:
- the timed out transactions count
-
getRecoveryManager
public LocalRecoveryManager getRecoveryManager()
Get the local transactions recovery manager of this cache manager- Returns:
- the local transactions recovery manager
-
-