com.hazelcast.hibernate.access
Class ReadOnlyAccessDelegate<T extends HazelcastRegion>

java.lang.Object
  extended by com.hazelcast.hibernate.access.AbstractAccessDelegate<T>
      extended by com.hazelcast.hibernate.access.NonStrictReadWriteAccessDelegate<T>
          extended by com.hazelcast.hibernate.access.ReadOnlyAccessDelegate<T>
Type Parameters:
T - implementation type of HazelcastRegion
All Implemented Interfaces:
AccessDelegate<T>

public class ReadOnlyAccessDelegate<T extends HazelcastRegion>
extends NonStrictReadWriteAccessDelegate<T>

Guarantees that view is read-only and no updates can be made

Author:
Leo Kim (lkim@limewire.com)

Field Summary
 
Fields inherited from class com.hazelcast.hibernate.access.AbstractAccessDelegate
cache, hazelcastRegion, log, versionComparator
 
Constructor Summary
ReadOnlyAccessDelegate(T hazelcastRegion, Properties props)
           
 
Method Summary
 boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock)
          Called after an item has been updated (after the transaction completes), instead of calling release().
 SoftLock lockItem(Object key, Object version)
          We are going to attempt to update/delete the keyed object.
 SoftLock lockRegion()
          NO-OP
 void unlockItem(Object key, SoftLock lock)
          This will issue a log warning stating that an attempt was made to unlock an item from a read-only cache region.
 void unlockRegion(SoftLock lock)
          This will issue a log warning stating that an attempt was made to unlock a read-only cache region.
 boolean update(Object key, Object value, Object currentVersion, Object previousVersion)
          This is an asynchronous cache access strategy.
 
Methods inherited from class com.hazelcast.hibernate.access.NonStrictReadWriteAccessDelegate
afterInsert, putFromLoad
 
Methods inherited from class com.hazelcast.hibernate.access.AbstractAccessDelegate
evict, evictAll, get, getHazelcastRegion, insert, put, putFromLoad, remove, removeAll, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadOnlyAccessDelegate

public ReadOnlyAccessDelegate(T hazelcastRegion,
                              Properties props)
Method Detail

afterUpdate

public boolean afterUpdate(Object key,
                           Object value,
                           Object currentVersion,
                           Object previousVersion,
                           SoftLock lock)
                    throws org.hibernate.cache.CacheException
Description copied from interface: AccessDelegate
Called after an item has been updated (after the transaction completes), instead of calling release(). This method is used by "asynchronous" concurrency strategies.

Specified by:
afterUpdate in interface AccessDelegate<T extends HazelcastRegion>
Overrides:
afterUpdate in class NonStrictReadWriteAccessDelegate<T extends HazelcastRegion>
Parameters:
key - The item key
value - The item
currentVersion - The item's current version value
previousVersion - The item's previous version value
lock - The lock previously obtained from AccessDelegate.lockItem(java.lang.Object, java.lang.Object)
Returns:
Were the contents of the cache actual changed by this operation?
Throws:
UnsupportedOperationException
org.hibernate.cache.CacheException - Propogated from underlying org.hibernate.cache.Region

lockItem

public SoftLock lockItem(Object key,
                         Object version)
                  throws org.hibernate.cache.CacheException
Description copied from interface: AccessDelegate
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 AccessDelegate<T extends HazelcastRegion>
Overrides:
lockItem in class NonStrictReadWriteAccessDelegate<T extends HazelcastRegion>
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:
UnsupportedOperationException
org.hibernate.cache.CacheException - Propogated from underlying org.hibernate.cache.Region

lockRegion

public SoftLock lockRegion()
                    throws org.hibernate.cache.CacheException
Description copied from class: AbstractAccessDelegate
NO-OP

Specified by:
lockRegion in interface AccessDelegate<T extends HazelcastRegion>
Overrides:
lockRegion in class AbstractAccessDelegate<T extends HazelcastRegion>
Returns:
A representation of our lock on the item; or null.
Throws:
UnsupportedOperationException
org.hibernate.cache.CacheException - Propogated from underlying org.hibernate.cache.Region

unlockItem

public void unlockItem(Object key,
                       SoftLock lock)
                throws org.hibernate.cache.CacheException
This will issue a log warning stating that an attempt was made to unlock an item from a read-only cache region.

Specified by:
unlockItem in interface AccessDelegate<T extends HazelcastRegion>
Overrides:
unlockItem in class NonStrictReadWriteAccessDelegate<T extends HazelcastRegion>
Parameters:
key - The item key
lock - The lock previously obtained from AccessDelegate.lockItem(java.lang.Object, java.lang.Object)
Throws:
org.hibernate.cache.CacheException - Propogated from underlying org.hibernate.cache.Region

unlockRegion

public void unlockRegion(SoftLock lock)
                  throws org.hibernate.cache.CacheException
This will issue a log warning stating that an attempt was made to unlock a read-only cache region.

Specified by:
unlockRegion in interface AccessDelegate<T extends HazelcastRegion>
Overrides:
unlockRegion in class NonStrictReadWriteAccessDelegate<T extends HazelcastRegion>
Parameters:
lock - The lock previously obtained from AccessDelegate.lockRegion()
Throws:
org.hibernate.cache.CacheException - Propogated from underlying org.hibernate.cache.Region

update

public boolean update(Object key,
                      Object value,
                      Object currentVersion,
                      Object previousVersion)
               throws org.hibernate.cache.CacheException
Description copied from class: AbstractAccessDelegate
This is an asynchronous cache access strategy. NO-OP

Specified by:
update in interface AccessDelegate<T extends HazelcastRegion>
Overrides:
update in class AbstractAccessDelegate<T extends HazelcastRegion>
Parameters:
key - The item key
value - The item
currentVersion - The item's current version value
previousVersion - The item's previous version value
Returns:
Were the contents of the cache actual changed by this operation?
Throws:
UnsupportedOperationException
org.hibernate.cache.CacheException - Propogated from underlying org.hibernate.cache.Region


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.