ehcache

net.sf.ehcache.transaction.local
Class LocalTransactionContext

java.lang.Object
  extended by net.sf.ehcache.transaction.local.LocalTransactionContext

public class LocalTransactionContext
extends Object

A local transaction's thread context

Author:
Ludovic Orban

Constructor Summary
LocalTransactionContext(int transactionTimeout, TransactionIDFactory transactionIdFactory)
          Create a new LocalTransactionContext
 
Method Summary
 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(Object obj)
          
 List<SoftLock> getSoftLocksForCache(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(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
 void updateSoftLock(String cacheName, SoftLock softLock)
          Update a soft lock already registered in the context
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalTransactionContext

public LocalTransactionContext(int transactionTimeout,
                               TransactionIDFactory transactionIdFactory)
Create a new LocalTransactionContext

Parameters:
transactionTimeout - the timeout before the context expires
transactionIdFactory - 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(String cacheName,
                             LocalTransactionStore store,
                             SoftLock softLock)
Register a soft lock in the context

Parameters:
cacheName - the name of the cache this soft lock is in
store - the LocalTransactionStore this soft lock is in
softLock - the soft lock

updateSoftLock

public void updateSoftLock(String cacheName,
                           SoftLock softLock)
Update a soft lock already registered in the context

Parameters:
cacheName - the name of the cache this soft lock is in
softLock - the soft lock

getSoftLocksForCache

public List<SoftLock> getSoftLocksForCache(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:
hashCode in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

ehcache

Copyright 2001-2015, Terracotta, Inc.