org.hibernate.cache.ehcache.internal.regions
Class EhcacheTransactionalDataRegion

java.lang.Object
  extended by org.hibernate.cache.ehcache.internal.regions.EhcacheDataRegion
      extended by org.hibernate.cache.ehcache.internal.regions.EhcacheTransactionalDataRegion
All Implemented Interfaces:
Region, TransactionalDataRegion
Direct Known Subclasses:
EhcacheCollectionRegion, EhcacheEntityRegion, EhcacheNaturalIdRegion

public class EhcacheTransactionalDataRegion
extends EhcacheDataRegion
implements TransactionalDataRegion

An Ehcache specific TransactionalDataRegion.

This is the common superclass entity and collection regions.


Field Summary
protected  CacheDataDescription metadata
          Metadata associated with the objects stored in the region.
protected  Settings settings
          Hibernate settings associated with the persistence unit.
 
Fields inherited from class org.hibernate.cache.ehcache.internal.regions.EhcacheDataRegion
accessStrategyFactory, cache
 
Method Summary
 void clear()
          Remove all mapping from this cache region.
 Object get(Object key)
          Get the value mapped to this key, or null if no value is mapped to this key.
 CacheDataDescription getCacheDataDescription()
          
 Settings getSettings()
          Return the hibernate settings
 boolean isTransactionAware()
          Is the underlying cache implementation aware of (and "participating in") ongoing JTA transactions?

Regions which report that they are transaction-aware are considered "synchronous", in that we assume we can immediately (i.e.

 boolean locksAreIndependentOfCache()
          Returns true if the locks used by the locking methods of this region are the independent of the cache.
 void put(Object key, Object value)
          Map the given value to the given key, replacing any existing mapping for this key
 void readLock(Object key)
          Attempts to read lock the mapping for the given key.
 void readUnlock(Object key)
          Attempts to read unlock the mapping for the given key.
 void remove(Object key)
          Remove the mapping for this key (if any exists).
 void writeLock(Object key)
          Attempts to write lock the mapping for the given key.
 void writeUnlock(Object key)
          Attempts to write unlock the mapping for the given key.
 
Methods inherited from class org.hibernate.cache.ehcache.internal.regions.EhcacheDataRegion
contains, destroy, getEhcache, getElementCountInMemory, getElementCountOnDisk, getName, getSizeInMemory, getTimeout, nextTimestamp, toMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.hibernate.cache.spi.Region
contains, destroy, getElementCountInMemory, getElementCountOnDisk, getName, getSizeInMemory, getTimeout, nextTimestamp, toMap
 

Field Detail

settings

protected final Settings settings
Hibernate settings associated with the persistence unit.


metadata

protected final CacheDataDescription metadata
Metadata associated with the objects stored in the region.

Method Detail

getSettings

public Settings getSettings()
Return the hibernate settings

Returns:
settings

isTransactionAware

public boolean isTransactionAware()
Is the underlying cache implementation aware of (and "participating in") ongoing JTA transactions?

Regions which report that they are transaction-aware are considered "synchronous", in that we assume we can immediately (i.e. synchronously) write the changes to the cache and that the cache will properly manage application of the written changes within the bounds of ongoing JTA transactions. Conversely, regions reporting false are considered "asynchronous", where it is assumed that changes must be manually delayed by Hibernate until we are certain that the current transaction is successful (i.e. maintaining READ_COMMITTED isolation).

Specified by:
isTransactionAware in interface TransactionalDataRegion
Returns:
True if transaction aware; false otherwise.

getCacheDataDescription

public CacheDataDescription getCacheDataDescription()

Specified by:
getCacheDataDescription in interface TransactionalDataRegion

get

public final Object get(Object key)
Get the value mapped to this key, or null if no value is mapped to this key.


put

public final void put(Object key,
                      Object value)
               throws CacheException
Map the given value to the given key, replacing any existing mapping for this key

Throws:
CacheException

remove

public final void remove(Object key)
                  throws CacheException
Remove the mapping for this key (if any exists).

Throws:
CacheException

clear

public final void clear()
                 throws CacheException
Remove all mapping from this cache region.

Throws:
CacheException

writeLock

public final void writeLock(Object key)
Attempts to write lock the mapping for the given key.


writeUnlock

public final void writeUnlock(Object key)
Attempts to write unlock the mapping for the given key.


readLock

public final void readLock(Object key)
Attempts to read lock the mapping for the given key.


readUnlock

public final void readUnlock(Object key)
Attempts to read unlock the mapping for the given key.


locksAreIndependentOfCache

public final boolean locksAreIndependentOfCache()
Returns true if the locks used by the locking methods of this region are the independent of the cache.

Independent locks are not locked by the cache when the cache is accessed directly. This means that for an independent lock lock holds taken through a region method will not block direct access to the cache via other means.



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