Top Description Fields Constructors Methods
net.sf.ehcache.hibernate.nonstop

public Class NonstopAwareEntityRegionAccessStrategy

extends Object
implements EntityRegionAccessStrategy
Class Inheritance
All Implemented Interfaces
org.hibernate.cache.access.EntityRegionAccessStrategy
Imports
net.sf.ehcache.constructs.nonstop.NonStopCacheException, org.hibernate.cache.CacheException, .EntityRegion, org.hibernate.cache.access.EntityRegionAccessStrategy, .SoftLock

Implementation of EntityRegionAccessStrategy that handles NonStopCacheException using HibernateNonstopCacheExceptionHandler
Author
Abhishek Sanoujam

Field Summary

Modifier and TypeField and Description
private final EntityRegionAccessStrategy
private final HibernateNonstopCacheExceptionHandler

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
afterInsert(Object
The item key
key
,
Object
The item
value
,
Object
The item's version value
version
)

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.afterInsert.

Called after an item has been inserted (after the transaction completes), instead of calling release().
public boolean
afterUpdate(Object
The item key
key
,
Object
The item
value
,
Object
The item's current version value
currentVersion
,
Object
The item's previous version value
previousVersion
,
SoftLock
The lock previously obtained from lockItem
lock
)

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.afterUpdate.

Called after an item has been updated (after the transaction completes), instead of calling release().
public void
evict(Object
The key of the item to remove
key
)

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.evict.

Forcibly evict an item from the cache immediately without regard for transaction isolation.
public void
evictAll()

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.evictAll.

Forcibly evict all items from the cache immediately without regard for transaction isolation.
public Object
get(Object
The key of the item to be retrieved.
key
,
long
a timestamp prior to the transaction start time
txTimestamp
)

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.get.

Attempt to retrieve an object from the cache.
public EntityRegion
getRegion()

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.getRegion.

Get the wrapped entity cache region
public boolean
insert(Object
The item key
key
,
Object
The item
value
,
Object
The item's version value
version
)

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.insert.

Called after an item has been inserted (before the transaction completes), instead of calling evict().
public SoftLock
lockItem(Object
The key of the item to lock
key
,
Object
The item's current version value
version
)

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.lockItem.

We are going to attempt to update/delete the keyed object.
public SoftLock
public boolean
putFromLoad(Object
The item key
key
,
Object
The item
value
,
long
a timestamp prior to the transaction start time
txTimestamp
,
Object
the item version number
version
,
boolean
Explicit minimalPut flag
minimalPutOverride
)

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.putFromLoad.

Attempt to cache an object, after loading from the database, explicitly specifying the minimalPut behavior.
public boolean
putFromLoad(Object
The item key
key
,
Object
The item
value
,
long
a timestamp prior to the transaction start time
txTimestamp
,
Object
the item version number
version
)

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.putFromLoad.

Attempt to cache an object, after loading from the database.
public void
remove(Object
The key of the item to remove
key
)

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.remove.

Called after an item has become stale (before the transaction completes).
public void
removeAll()

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.removeAll.

Called to evict data from the entire region
public void
unlockItem(Object
The item key
key
,
SoftLock
The lock previously obtained from lockItem
lock
)

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.unlockItem.

Called when we have finished the attempted update/delete (which may or may not have been successful), after transaction completion.
public void
unlockRegion(SoftLock
The lock previously obtained from lockRegion
lock
)

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.unlockRegion.

Called after we have finished the attempted invalidation of the entire region
public boolean
update(Object
The item key
key
,
Object
The item
value
,
Object
The item's current version value
currentVersion
,
Object
The item's previous version value
previousVersion
)

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.update.

Called after an item has been updated (before the transaction completes), instead of calling evict().
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

actualStrategyback to summary
private final EntityRegionAccessStrategy actualStrategy
hibernateNonstopExceptionHandlerback to summary
private final HibernateNonstopCacheExceptionHandler hibernateNonstopExceptionHandler

Constructor Detail

NonstopAwareEntityRegionAccessStrategyback to summary
public NonstopAwareEntityRegionAccessStrategy(EntityRegionAccessStrategy actualStrategy, HibernateNonstopCacheExceptionHandler hibernateNonstopExceptionHandler)

Constructor accepting the actual EntityRegionAccessStrategy and the HibernateNonstopCacheExceptionHandler

Method Detail

afterInsertback to summary
public boolean afterInsert(Object key, Object value, Object version) throws CacheException

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.afterInsert.

Doc from org.hibernate.cache.access.EntityRegionAccessStrategy.afterInsert.

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:Object

The item key

value:Object

The item

version:Object

The item's version value

Returns:boolean

Were the contents of the cache actual changed by this operation?

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
See Also
org.hibernate.cache.access.EntityRegionAccessStrategy#afterInsert(java.lang.Object, java.lang.Object, java.lang.Object)
afterUpdateback to summary
public boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock) throws CacheException

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.afterUpdate.

Doc from org.hibernate.cache.access.EntityRegionAccessStrategy.afterUpdate.

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:Object

The item key

value:Object

The item

currentVersion:Object

The item's current version value

previousVersion:Object

The item's previous version value

lock:SoftLock

The lock previously obtained from lockItem

Returns:boolean

Were the contents of the cache actual changed by this operation?

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
See Also
org.hibernate.cache.access.EntityRegionAccessStrategy#afterUpdate(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, org.hibernate.cache.access.SoftLock)
evictback to summary
public void evict(Object key) throws CacheException

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.evict.

Doc from org.hibernate.cache.access.EntityRegionAccessStrategy.evict.

Forcibly evict an item from the cache immediately without regard for transaction isolation.

Parameters
key:Object

The key of the item to remove

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
See Also
org.hibernate.cache.access.EntityRegionAccessStrategy#evict(java.lang.Object)
evictAllback to summary
public void evictAll() throws CacheException

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.evictAll.

Doc from org.hibernate.cache.access.EntityRegionAccessStrategy.evictAll.

Forcibly evict all items from the cache immediately without regard for transaction isolation.

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
See Also
org.hibernate.cache.access.EntityRegionAccessStrategy#evictAll()
getback to summary
public Object get(Object key, long txTimestamp) throws CacheException

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.get.

Doc from org.hibernate.cache.access.EntityRegionAccessStrategy.get.

Attempt to retrieve an object from the cache. Mainly used in attempting to resolve entities/collections from the second level cache.

Parameters
key:Object

The key of the item to be retrieved.

txTimestamp:long

a timestamp prior to the transaction start time

Returns:Object

the cached object or null

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
See Also
org.hibernate.cache.access.EntityRegionAccessStrategy#get(java.lang.Object, long)
getRegionback to summary
public EntityRegion getRegion()

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.getRegion.

Doc from org.hibernate.cache.access.EntityRegionAccessStrategy.getRegion.

Get the wrapped entity cache region

Returns:EntityRegion

The underlying region

See Also
org.hibernate.cache.access.EntityRegionAccessStrategy#getRegion()
insertback to summary
public boolean insert(Object key, Object value, Object version) throws CacheException

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.insert.

Doc from org.hibernate.cache.access.EntityRegionAccessStrategy.insert.

Called after an item has been inserted (before the transaction completes), instead of calling evict(). This method is used by "synchronous" concurrency strategies.

Parameters
key:Object

The item key

value:Object

The item

version:Object

The item's version value

Returns:boolean

Were the contents of the cache actual changed by this operation?

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
See Also
org.hibernate.cache.access.EntityRegionAccessStrategy#insert(java.lang.Object, java.lang.Object, java.lang.Object)
lockItemback to summary
public SoftLock lockItem(Object key, Object version) throws CacheException

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.lockItem.

Doc from org.hibernate.cache.access.EntityRegionAccessStrategy.lockItem.

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:Object

The key of the item to lock

version:Object

The item's current version value

Returns:SoftLock

A representation of our lock on the item; or null.

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
See Also
org.hibernate.cache.access.EntityRegionAccessStrategy#lockItem(java.lang.Object, java.lang.Object)
lockRegionback to summary
public SoftLock lockRegion() throws CacheException

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.lockRegion.

Doc from org.hibernate.cache.access.EntityRegionAccessStrategy.lockRegion.

Lock the entire region

Returns:SoftLock

A representation of our lock on the item; or null.

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
See Also
org.hibernate.cache.access.EntityRegionAccessStrategy#lockRegion()
putFromLoadback to summary
public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride) throws CacheException

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.putFromLoad.

Doc from org.hibernate.cache.access.EntityRegionAccessStrategy.putFromLoad.

Attempt to cache an object, after loading from the database, explicitly specifying the minimalPut behavior.

Parameters
key:Object

The item key

value:Object

The item

txTimestamp:long

a timestamp prior to the transaction start time

version:Object

the item version number

minimalPutOverride:boolean

Explicit minimalPut flag

Returns:boolean

true if the object was successfully cached

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
See Also
org.hibernate.cache.access.EntityRegionAccessStrategy#putFromLoad(java.lang.Object, java.lang.Object, long, java.lang.Object, boolean)
putFromLoadback to summary
public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version) throws CacheException

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.putFromLoad.

Doc from org.hibernate.cache.access.EntityRegionAccessStrategy.putFromLoad.

Attempt to cache an object, after loading from the database.

Parameters
key:Object

The item key

value:Object

The item

txTimestamp:long

a timestamp prior to the transaction start time

version:Object

the item version number

Returns:boolean

true if the object was successfully cached

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
See Also
org.hibernate.cache.access.EntityRegionAccessStrategy#putFromLoad(java.lang.Object, java.lang.Object, long, java.lang.Object)
removeback to summary
public void remove(Object key) throws CacheException

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.remove.

Doc from org.hibernate.cache.access.EntityRegionAccessStrategy.remove.

Called after an item has become stale (before the transaction completes). This method is used by "synchronous" concurrency strategies.

Parameters
key:Object

The key of the item to remove

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
See Also
org.hibernate.cache.access.EntityRegionAccessStrategy#remove(java.lang.Object)
removeAllback to summary
public void removeAll() throws CacheException

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.removeAll.

Doc from org.hibernate.cache.access.EntityRegionAccessStrategy.removeAll.

Called to evict data from the entire region

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
See Also
org.hibernate.cache.access.EntityRegionAccessStrategy#removeAll()
unlockItemback to summary
public void unlockItem(Object key, SoftLock lock) throws CacheException

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.unlockItem.

Doc from org.hibernate.cache.access.EntityRegionAccessStrategy.unlockItem.

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:Object

The item key

lock:SoftLock

The lock previously obtained from lockItem

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
See Also
org.hibernate.cache.access.EntityRegionAccessStrategy#unlockItem(java.lang.Object, org.hibernate.cache.access.SoftLock)
unlockRegionback to summary
public void unlockRegion(SoftLock lock) throws CacheException

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.unlockRegion.

Doc from org.hibernate.cache.access.EntityRegionAccessStrategy.unlockRegion.

Called after we have finished the attempted invalidation of the entire region

Parameters
lock:SoftLock

The lock previously obtained from lockRegion

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
See Also
org.hibernate.cache.access.EntityRegionAccessStrategy#unlockRegion(org.hibernate.cache.access.SoftLock)
updateback to summary
public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException

Implements org.hibernate.cache.access.EntityRegionAccessStrategy.update.

Doc from org.hibernate.cache.access.EntityRegionAccessStrategy.update.

Called after an item has been updated (before the transaction completes), instead of calling evict(). This method is used by "synchronous" concurrency strategies.

Parameters
key:Object

The item key

value:Object

The item

currentVersion:Object

The item's current version value

previousVersion:Object

The item's previous version value

Returns:boolean

Were the contents of the cache actual changed by this operation?

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
See Also
org.hibernate.cache.access.EntityRegionAccessStrategy#update(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object)