public class LocalTransactionContext
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private long |
expirationTimestamp |
private java.util.List<TransactionListener> |
listeners |
private static org.slf4j.Logger |
LOG |
private boolean |
rollbackOnly |
private java.util.Map<java.lang.String,java.util.List<SoftLock>> |
softLockMap |
private java.util.Map<java.lang.String,LocalTransactionStore> |
storeMap |
private TransactionID |
transactionId |
private TransactionIDFactory |
transactionIdFactory |
Constructor and Description |
---|
LocalTransactionContext(int transactionTimeout,
TransactionIDFactory transactionIdFactory)
Create a new LocalTransactionContext
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(TransactionListener listener)
Add a TransactionListener to this context
|
void |
commit(boolean ignoreTimeout)
Commit all work done in the context and release all registered soft locks
|
boolean |
equals(java.lang.Object obj) |
private void |
fireAfterCommitEvent() |
private void |
fireAfterRollbackEvent() |
private void |
fireBeforeCommitEvent() |
private void |
freeze() |
java.util.List<SoftLock> |
getSoftLocksForCache(java.lang.String cacheName)
Get all soft locks registered in this context for a specific cache
|
TransactionID |
getTransactionId()
Get the transaction ID of the context
|
int |
hashCode() |
boolean |
hasLockedAnything()
Check if anything was locked in this transaction's context
|
void |
registerSoftLock(java.lang.String cacheName,
LocalTransactionStore store,
SoftLock softLock)
Register a soft lock in the context
|
void |
rollback()
Rollback all work done in the context and release all registered soft locks
|
void |
setRollbackOnly()
Mark the context for rollback
|
long |
timeBeforeTimeout()
Get the time until this context will expire
|
boolean |
timedOut()
Check if the context timed out
|
private void |
unfreezeAndUnlock() |
void |
updateSoftLock(java.lang.String cacheName,
SoftLock softLock)
Update a soft lock already registered in the context
|
private static final org.slf4j.Logger LOG
private boolean rollbackOnly
private final long expirationTimestamp
private final TransactionIDFactory transactionIdFactory
private final TransactionID transactionId
private final java.util.Map<java.lang.String,java.util.List<SoftLock>> softLockMap
private final java.util.Map<java.lang.String,LocalTransactionStore> storeMap
private final java.util.List<TransactionListener> listeners
public LocalTransactionContext(int transactionTimeout, TransactionIDFactory transactionIdFactory)
transactionTimeout
- the timeout before the context expirestransactionIdFactory
- the transaction ID factory to retrieve a new transaction id frompublic boolean timedOut()
public long timeBeforeTimeout()
public void setRollbackOnly()
public void registerSoftLock(java.lang.String cacheName, LocalTransactionStore store, SoftLock softLock)
cacheName
- the name of the cache this soft lock is instore
- the LocalTransactionStore this soft lock is insoftLock
- the soft lockpublic void updateSoftLock(java.lang.String cacheName, SoftLock softLock)
cacheName
- the name of the cache this soft lock is insoftLock
- the soft lockpublic java.util.List<SoftLock> getSoftLocksForCache(java.lang.String cacheName)
cacheName
- the name of the cachepublic boolean hasLockedAnything()
public void commit(boolean ignoreTimeout)
ignoreTimeout
- true if commit should proceed no matter the timeoutpublic void rollback()
public TransactionID getTransactionId()
public void addListener(TransactionListener listener)
listener
- the listenerprivate void fireBeforeCommitEvent()
private void fireAfterCommitEvent()
private void fireAfterRollbackEvent()
private void unfreezeAndUnlock()
private void freeze()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object