Package net.sf.ehcache.transaction.local
Class LocalTransactionContext
- java.lang.Object
-
- net.sf.ehcache.transaction.local.LocalTransactionContext
-
public class LocalTransactionContext extends java.lang.ObjectA local transaction's thread context- Author:
- Ludovic Orban
-
-
Constructor Summary
Constructors Constructor Description LocalTransactionContext(int transactionTimeout, TransactionIDFactory transactionIdFactory)Create a new LocalTransactionContext
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(TransactionListener listener)Add a TransactionListener to this contextvoidcommit(boolean ignoreTimeout)Commit all work done in the context and release all registered soft locksbooleanequals(java.lang.Object obj)java.util.List<SoftLock>getSoftLocksForCache(java.lang.String cacheName)Get all soft locks registered in this context for a specific cacheTransactionIDgetTransactionId()Get the transaction ID of the contextinthashCode()booleanhasLockedAnything()Check if anything was locked in this transaction's contextvoidregisterSoftLock(java.lang.String cacheName, LocalTransactionStore store, SoftLock softLock)Register a soft lock in the contextvoidrollback()Rollback all work done in the context and release all registered soft locksvoidsetRollbackOnly()Mark the context for rollbacklongtimeBeforeTimeout()Get the time until this context will expirebooleantimedOut()Check if the context timed outvoidupdateSoftLock(java.lang.String cacheName, SoftLock softLock)Update a soft lock already registered in the context
-
-
-
Constructor Detail
-
LocalTransactionContext
public LocalTransactionContext(int transactionTimeout, TransactionIDFactory transactionIdFactory)Create a new LocalTransactionContext- Parameters:
transactionTimeout- the timeout before the context expirestransactionIdFactory- the transaction ID factory to retrieve a new transaction id from
-
-
Method Detail
-
timedOut
public boolean timedOut()
Check if the context timed out- Returns:
- true if the context timed out, false otherwise
-
timeBeforeTimeout
public long timeBeforeTimeout()
Get the time until this context will expire- Returns:
- the time in milliseconds after which this context will expire
-
setRollbackOnly
public void setRollbackOnly()
Mark the context for rollback
-
registerSoftLock
public void registerSoftLock(java.lang.String cacheName, LocalTransactionStore store, SoftLock softLock)Register a soft lock in the context- Parameters:
cacheName- the name of the cache this soft lock is instore- the LocalTransactionStore this soft lock is insoftLock- the soft lock
-
updateSoftLock
public void updateSoftLock(java.lang.String cacheName, SoftLock softLock)Update a soft lock already registered in the context- Parameters:
cacheName- the name of the cache this soft lock is insoftLock- the soft lock
-
getSoftLocksForCache
public java.util.List<SoftLock> getSoftLocksForCache(java.lang.String cacheName)
Get all soft locks registered in this context for a specific cache- Parameters:
cacheName- the name of the cache- Returns:
- a List of registered soft locks for this cache
-
hasLockedAnything
public boolean hasLockedAnything()
Check if anything was locked in this transaction's context- Returns:
- true if at least one soft lock got registered, false otherwise
-
commit
public void commit(boolean ignoreTimeout)
Commit all work done in the context and release all registered soft locks- Parameters:
ignoreTimeout- true if commit should proceed no matter the timeout
-
rollback
public void rollback()
Rollback all work done in the context and release all registered soft locks
-
getTransactionId
public TransactionID getTransactionId()
Get the transaction ID of the context- Returns:
- the transaction ID
-
addListener
public void addListener(TransactionListener listener)
Add a TransactionListener to this context- Parameters:
listener- the listener
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-