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

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

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

Makes no guarantee of consistency between the cache and the database. Stale data from the cache is possible if expiry is not configured appropriately.

Author:
Leo Kim (lkim@limewire.com)

Field Summary
 
Fields inherited from class com.hazelcast.hibernate.access.AbstractAccessDelegate
cache, hazelcastRegion, log, versionComparator
 
Constructor Summary
NonStrictReadWriteAccessDelegate(T hazelcastRegion, Properties props)
           
 
Method Summary
 boolean afterInsert(Object key, Object value, Object version)
          Called after an item has been inserted (after the transaction completes), instead of calling release().
 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.
 boolean putFromLoad(Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride)
          Attempt to cache an object, after loading from the database, explicitly specifying the minimalPut behavior.
 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.
 void unlockRegion(SoftLock lock)
          NO-OP
 
Methods inherited from class com.hazelcast.hibernate.access.AbstractAccessDelegate
evict, evictAll, get, getHazelcastRegion, insert, lockRegion, put, putFromLoad, remove, removeAll, update, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NonStrictReadWriteAccessDelegate

public NonStrictReadWriteAccessDelegate(T hazelcastRegion,
                                        Properties props)
Method Detail

afterInsert

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

Parameters:
key - The item key
value - The item
version - The item's version value
Returns:
Were the contents of the cache actual changed by this operation?
Throws:
org.hibernate.cache.CacheException - Propogated from underlying org.hibernate.cache.Region

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.

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:
org.hibernate.cache.CacheException - Propogated from underlying org.hibernate.cache.Region

putFromLoad

public boolean putFromLoad(Object key,
                           Object value,
                           long txTimestamp,
                           Object version,
                           boolean minimalPutOverride)
                    throws org.hibernate.cache.CacheException
Description copied from interface: AccessDelegate
Attempt to cache an object, after loading from the database, explicitly specifying the minimalPut behavior.

Parameters:
key - The item key
value - The item
txTimestamp - a timestamp prior to the transaction start time
version - the item version number
minimalPutOverride - Explicit minimalPut flag
Returns:
true if the object was successfully cached
Throws:
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.

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:
org.hibernate.cache.CacheException - Propogated from underlying org.hibernate.cache.Region

unlockItem

public void unlockItem(Object key,
                       SoftLock lock)
                throws org.hibernate.cache.CacheException
Description copied from interface: AccessDelegate
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.

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
Description copied from class: AbstractAccessDelegate
NO-OP

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


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