ehcache

net.sf.ehcache.util
Class CacheTransactionHelper

java.lang.Object
  extended by net.sf.ehcache.util.CacheTransactionHelper

public class CacheTransactionHelper
extends Object

A collection of utility methods helping controlling transactions for managed operations which may require them.

Author:
Ludovic Orban

Constructor Summary
CacheTransactionHelper()
           
 
Method Summary
static void beginTransactionIfNeeded(Ehcache cache)
          Begin a transaction on the current thread if the cache is configured as transactional, otherwise this method does nothing.
static void commitTransactionIfNeeded(Ehcache cache)
          Commit a transaction previously begun on the current thread if the cache is configured as transactional, otherwise this method does nothing.
static boolean isTransactionStarted(Ehcache cache)
          Check if a transaction has begun on the current thread if the cache is configured as transactional, otherwise always return false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheTransactionHelper

public CacheTransactionHelper()
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

ehcache

Copyright 2001-2015, Terracotta, Inc.