org.hibernate.cache.infinispan.util
Class Caches

java.lang.Object
  extended by org.hibernate.cache.infinispan.util.Caches

public class Caches
extends Object

Helper for dealing with Infinispan cache instances.

Since:
4.1

Method Summary
static org.infinispan.AdvancedCache asyncWriteCache(org.infinispan.AdvancedCache cache, org.infinispan.context.Flag extraFlag)
          Transform a given cache into a cache that writes cache entries without waiting for them to complete, adding an extra flag.
static void broadcastEvictAll(org.infinispan.AdvancedCache cache)
          Broadcast an evict-all command with the given cache instance.
static org.infinispan.AdvancedCache failSilentReadCache(org.infinispan.AdvancedCache cache)
          Transform a given cache into a cache that fails silently if cache reads fail.
static org.infinispan.AdvancedCache failSilentWriteCache(org.infinispan.AdvancedCache cache)
          Transform a given cache into a cache that fails silently if cache writes fail.
static org.infinispan.AdvancedCache failSilentWriteCache(org.infinispan.AdvancedCache cache, org.infinispan.context.Flag extraFlag)
          Transform a given cache into a cache that fails silently if cache writes fail, adding an extra flag.
static org.infinispan.AdvancedCache ignoreReturnValuesCache(org.infinispan.AdvancedCache cache)
          Transform a given cache into a cache that ignores return values for operations returning previous values, i.e.
static org.infinispan.AdvancedCache ignoreReturnValuesCache(org.infinispan.AdvancedCache cache, org.infinispan.context.Flag extraFlag)
          Transform a given cache into a cache that ignores return values for operations returning previous values, i.e.
static boolean isClustered(org.infinispan.AdvancedCache cache)
          Indicates whether the given cache is configured to cluster its contents.
static boolean isInvalidationCache(org.infinispan.AdvancedCache cache)
          Indicates whether the given cache is configured with CacheMode.INVALIDATION_ASYNC or CacheMode.INVALIDATION_SYNC.
static boolean isSynchronousCache(org.infinispan.AdvancedCache cache)
          Indicates whether the given cache is configured with CacheMode.REPL_SYNC, CacheMode.INVALIDATION_SYNC, or CacheMode.DIST_SYNC.
static org.infinispan.AdvancedCache localCache(org.infinispan.AdvancedCache cache)
          Transform a given cache into a local cache
static void removeAll(org.infinispan.AdvancedCache cache)
           
static
<T> T
withinTx(org.infinispan.AdvancedCache cache, Callable<T> c)
          Call an operation within a transaction.
static
<T> T
withinTx(TransactionManager tm, Callable<T> c)
          Call an operation within a transaction.
static void withinTx(TransactionManager tm, Runnable runnable)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

withinTx

public static <T> T withinTx(org.infinispan.AdvancedCache cache,
                             Callable<T> c)
                  throws Exception
Call an operation within a transaction. This method guarantees that the right pattern is used to make sure that the transaction is always either committed or rollback.

Type Parameters:
T - type of callable return
Parameters:
cache - instance whose transaction manager to use
c - callable instance to run within a transaction
Returns:
returns whatever the callable returns
Throws:
Exception - if any operation within the transaction fails

withinTx

public static <T> T withinTx(TransactionManager tm,
                             Callable<T> c)
                  throws Exception
Call an operation within a transaction. This method guarantees that the right pattern is used to make sure that the transaction is always either committed or rollbacked.

Type Parameters:
T - type of callable return
Parameters:
tm - transaction manager
c - callable instance to run within a transaction
Returns:
returns whatever the callable returns
Throws:
Exception - if any operation within the transaction fails

withinTx

public static void withinTx(TransactionManager tm,
                            Runnable runnable)
                     throws Exception
Throws:
Exception

localCache

public static org.infinispan.AdvancedCache localCache(org.infinispan.AdvancedCache cache)
Transform a given cache into a local cache

Parameters:
cache - to be transformed
Returns:
a cache that operates only in local-mode

ignoreReturnValuesCache

public static org.infinispan.AdvancedCache ignoreReturnValuesCache(org.infinispan.AdvancedCache cache)
Transform a given cache into a cache that ignores return values for operations returning previous values, i.e. BasicCache.put(Object, Object)

Parameters:
cache - to be transformed
Returns:
a cache that ignores return values

ignoreReturnValuesCache

public static org.infinispan.AdvancedCache ignoreReturnValuesCache(org.infinispan.AdvancedCache cache,
                                                                   org.infinispan.context.Flag extraFlag)
Transform a given cache into a cache that ignores return values for operations returning previous values, i.e. BasicCache.put(Object, Object), adding an extra flag.

Parameters:
cache - to be transformed
extraFlag - to add to the returned cache
Returns:
a cache that ignores return values

asyncWriteCache

public static org.infinispan.AdvancedCache asyncWriteCache(org.infinispan.AdvancedCache cache,
                                                           org.infinispan.context.Flag extraFlag)
Transform a given cache into a cache that writes cache entries without waiting for them to complete, adding an extra flag.

Parameters:
cache - to be transformed
extraFlag - to add to the returned cache
Returns:
a cache that writes asynchronously

failSilentWriteCache

public static org.infinispan.AdvancedCache failSilentWriteCache(org.infinispan.AdvancedCache cache)
Transform a given cache into a cache that fails silently if cache writes fail.

Parameters:
cache - to be transformed
Returns:
a cache that fails silently if cache writes fail

failSilentWriteCache

public static org.infinispan.AdvancedCache failSilentWriteCache(org.infinispan.AdvancedCache cache,
                                                                org.infinispan.context.Flag extraFlag)
Transform a given cache into a cache that fails silently if cache writes fail, adding an extra flag.

Parameters:
cache - to be transformed
extraFlag - to be added to returned cache
Returns:
a cache that fails silently if cache writes fail

failSilentReadCache

public static org.infinispan.AdvancedCache failSilentReadCache(org.infinispan.AdvancedCache cache)
Transform a given cache into a cache that fails silently if cache reads fail.

Parameters:
cache - to be transformed
Returns:
a cache that fails silently if cache reads fail

broadcastEvictAll

public static void broadcastEvictAll(org.infinispan.AdvancedCache cache)
Broadcast an evict-all command with the given cache instance.

Parameters:
cache - instance used to broadcast command

isInvalidationCache

public static boolean isInvalidationCache(org.infinispan.AdvancedCache cache)
Indicates whether the given cache is configured with CacheMode.INVALIDATION_ASYNC or CacheMode.INVALIDATION_SYNC.

Parameters:
cache - to check for invalidation configuration
Returns:
true if the cache is configured with invalidation, false otherwise

isSynchronousCache

public static boolean isSynchronousCache(org.infinispan.AdvancedCache cache)
Indicates whether the given cache is configured with CacheMode.REPL_SYNC, CacheMode.INVALIDATION_SYNC, or CacheMode.DIST_SYNC.

Parameters:
cache - to check for synchronous configuration
Returns:
true if the cache is configured with synchronous mode, false otherwise

isClustered

public static boolean isClustered(org.infinispan.AdvancedCache cache)
Indicates whether the given cache is configured to cluster its contents. A cache is considered to clustered if it's configured with any cache mode except CacheMode.LOCAL

Parameters:
cache - to check whether it clusters its contents
Returns:
true if the cache is configured with clustering, false otherwise

removeAll

public static void removeAll(org.infinispan.AdvancedCache cache)


Copyright © 2001-2015 Red Hat, Inc. All Rights Reserved.