org.codehaus.activespace.cache
Class TransactionalCache

java.lang.Object
  extended byorg.codehaus.activespace.cache.impl.CacheFacade
      extended byorg.codehaus.activespace.cache.TransactionalCache
All Implemented Interfaces:
javax.cache.Cache, Map
Direct Known Subclasses:
ClusteredCache

public class TransactionalCache
extends CacheFacade

TransactionalCache can be used by multiple threads concurrently and it will maintain a thread local transactional view of an underlying shared cache, tracking changes to the underlying cache, yet not applying them until a transaction commits. This allows many threads to concurrently modify the same cache concurrently and transactionally.

Version:
$Revision: 1.14 $

Nested Class Summary
protected static class TransactionalCache.ThreadLocalState
           
 
Nested classes inherited from class java.util.Map
Map.Entry
 
Constructor Summary
TransactionalCache(javax.cache.Cache backingCache)
           
 
Method Summary
protected  void clearThreadState(TransactionalCache.ThreadLocalState state)
           
protected  ThreadCache createCacheForCurrentThread(TransactionalCache.ThreadLocalState state)
           
protected  TransactionalCache.ThreadLocalState createThreadState(String id)
           
 TransactionalCacheCommand createTransactionCommand()
           
 javax.cache.Cache getBackingCache()
           
protected  javax.cache.Cache getDelegate()
           
 String getName()
           
 ThreadCache getThreadCache()
           
 ThreadCache getThreadCache(String originator)
          Returns the ThreadCache which is currently processing a transaction or null if no such local ThreadCache exists for the given ID
protected  TransactionalCache.ThreadLocalState getThreadState()
           
 TransactionRegistration getTransactionRegistration()
           
 boolean isModifiedInTransaction()
           
protected  void registerCacheWithTransactionManager(TransactionalCache.ThreadLocalState state)
          A hook to allow us to register the cache with the current transaction if one is in progress or start one if one is not.
 void resetLocalChanges()
           
 void setName(String name)
           
 void setThreadID(String id)
          A helper method used for testing, which allows the ID for a thread's cache to be explicitly configured rather than being randomly generated, which can make debugging easier.
 void setTransactionRegistration(TransactionRegistration transactionRegistration)
           
 String toString()
           
 
Methods inherited from class org.codehaus.activespace.cache.impl.CacheFacade
addListener, clear, containsKey, containsValue, entrySet, evict, get, getAll, getCacheEntry, getCacheStatistics, isEmpty, keySet, load, loadAll, peek, put, putAll, remove, removeListener, size, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.cache.Cache
equals, hashCode
 

Constructor Detail

TransactionalCache

public TransactionalCache(javax.cache.Cache backingCache)
Method Detail

toString

public String toString()

getName

public String getName()

setName

public void setName(String name)

getBackingCache

public javax.cache.Cache getBackingCache()

createTransactionCommand

public TransactionalCacheCommand createTransactionCommand()

resetLocalChanges

public void resetLocalChanges()

isModifiedInTransaction

public boolean isModifiedInTransaction()

getThreadCache

public ThreadCache getThreadCache()

getThreadCache

public ThreadCache getThreadCache(String originator)
Returns the ThreadCache which is currently processing a transaction or null if no such local ThreadCache exists for the given ID


getTransactionRegistration

public TransactionRegistration getTransactionRegistration()

setTransactionRegistration

public void setTransactionRegistration(TransactionRegistration transactionRegistration)

setThreadID

public void setThreadID(String id)
A helper method used for testing, which allows the ID for a thread's cache to be explicitly configured rather than being randomly generated, which can make debugging easier.


getDelegate

protected javax.cache.Cache getDelegate()
Specified by:
getDelegate in class CacheFacade

createThreadState

protected TransactionalCache.ThreadLocalState createThreadState(String id)

createCacheForCurrentThread

protected ThreadCache createCacheForCurrentThread(TransactionalCache.ThreadLocalState state)

getThreadState

protected TransactionalCache.ThreadLocalState getThreadState()

clearThreadState

protected void clearThreadState(TransactionalCache.ThreadLocalState state)

registerCacheWithTransactionManager

protected void registerCacheWithTransactionManager(TransactionalCache.ThreadLocalState state)
A hook to allow us to register the cache with the current transaction if one is in progress or start one if one is not.



Copyright © 2004 Protique, Ltd.. All Rights Reserved.