org.hibernate.cache.jbc2.collection
Class ReadOnlyAccess

java.lang.Object
  extended by org.hibernate.cache.jbc2.collection.TransactionalAccess
      extended by org.hibernate.cache.jbc2.collection.ReadOnlyAccess
All Implemented Interfaces:
CollectionRegionAccessStrategy

public class ReadOnlyAccess
extends TransactionalAccess

This defines the strategy for transactional access to collection data in a pessimistic-locking JBossCache using its 2.x APIs.

The read-only access to a JBossCache really is still transactional, just with the extra semantic or guarantee that we will not update data.

Author:
Steve Ebersole

Constructor Summary
ReadOnlyAccess(CollectionRegionImpl region)
          Create a provider of read-only access to the specific region.
 
Method Summary
 SoftLock lockItem(Object key, Object version)
          We are going to attempt to update/delete the keyed object. This method is used by "asynchronous" concurrency strategies.

The returned object must be passed back to release(), to release the lock. Concurrency strategies which do not support client-visible locks may silently return null.

 SoftLock lockRegion()
          Lock the entire region
 void unlockItem(Object key, SoftLock lock)
          Called when we have finished the attempted update/delete (which may or may not have been successful), after transaction completion. This method is used by "asynchronous" concurrency strategies.
 void unlockRegion(SoftLock lock)
          Called after we have finished the attempted invalidation of the entire region
 
Methods inherited from class org.hibernate.cache.jbc2.collection.TransactionalAccess
evict, evictAll, get, getRegion, putFromLoad, putFromLoad, remove, removeAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadOnlyAccess

public ReadOnlyAccess(CollectionRegionImpl region)
Create a provider of read-only access to the specific region.

Parameters:
region - The region to which this provides access.
Method Detail

lockItem

public SoftLock lockItem(Object key,
                         Object version)
                  throws CacheException
We are going to attempt to update/delete the keyed object. This method is used by "asynchronous" concurrency strategies.

The returned object must be passed back to release(), to release the lock. Concurrency strategies which do not support client-visible locks may silently return null.

Specified by:
lockItem in interface CollectionRegionAccessStrategy
Overrides:
lockItem in class TransactionalAccess
Parameters:
key - The key of the item to lock
version - The item's current version value
Returns:
A representation of our lock on the item; or null.
Throws:
CacheException - Propogated from underlying Region

lockRegion

public SoftLock lockRegion()
                    throws CacheException
Lock the entire region

Specified by:
lockRegion in interface CollectionRegionAccessStrategy
Overrides:
lockRegion in class TransactionalAccess
Returns:
A representation of our lock on the item; or null.
Throws:
CacheException - Propogated from underlying Region

unlockItem

public void unlockItem(Object key,
                       SoftLock lock)
                throws CacheException
Called when we have finished the attempted update/delete (which may or may not have been successful), after transaction completion. This method is used by "asynchronous" concurrency strategies.

Specified by:
unlockItem in interface CollectionRegionAccessStrategy
Overrides:
unlockItem in class TransactionalAccess
Parameters:
key - The item key
lock - The lock previously obtained from CollectionRegionAccessStrategy.lockItem(java.lang.Object, java.lang.Object)
Throws:
CacheException - Propogated from underlying Region

unlockRegion

public void unlockRegion(SoftLock lock)
                  throws CacheException
Called after we have finished the attempted invalidation of the entire region

Specified by:
unlockRegion in interface CollectionRegionAccessStrategy
Overrides:
unlockRegion in class TransactionalAccess
Parameters:
lock - The lock previously obtained from CollectionRegionAccessStrategy.lockRegion()
Throws:
CacheException - Propogated from underlying Region


Copyright © null-null Red Hat Middleware, LLC. All Rights Reserved