Package net.sf.ehcache.util
Class CacheTransactionHelper
- java.lang.Object
-
- net.sf.ehcache.util.CacheTransactionHelper
-
public class CacheTransactionHelper extends java.lang.ObjectA collection of utility methods helping controlling transactions for managed operations which may require them.- Author:
- Ludovic Orban
-
-
Constructor Summary
Constructors Constructor Description CacheTransactionHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidbeginTransactionIfNeeded(Ehcache cache)Begin a transaction on the current thread if the cache is configured as transactional, otherwise this method does nothing.static voidcommitTransactionIfNeeded(Ehcache cache)Commit a transaction previously begun on the current thread if the cache is configured as transactional, otherwise this method does nothing.static booleanisTransactionStarted(Ehcache cache)Check if a transaction has begun on the current thread if the cache is configured as transactional, otherwise always return false.
-
-
-
Method Detail
-
beginTransactionIfNeeded
public static void beginTransactionIfNeeded(Ehcache cache) throws CacheException
Begin a transaction on the current thread if the cache is configured as transactional, otherwise this method does nothing.- Parameters:
cache- the cache to begin a transaction for- Throws:
CacheException- if anything wrong happens
-
commitTransactionIfNeeded
public static void commitTransactionIfNeeded(Ehcache cache) throws CacheException
Commit a transaction previously begun on the current thread if the cache is configured as transactional, otherwise this method does nothing.- Parameters:
cache- the cache to commit a transaction for- Throws:
CacheException- if anything wrong happens
-
isTransactionStarted
public static boolean isTransactionStarted(Ehcache cache) throws CacheException
Check if a transaction has begun on the current thread if the cache is configured as transactional, otherwise always return false.- Parameters:
cache- the cache to check if a transaction started for- Returns:
- true if the cache is transactional and a transaction started, false otherwise
- Throws:
CacheException- if anything wrong happens
-
-