Package org.apache.openjpa.datacache
Class DelegatingQueryCache
java.lang.Object
org.apache.openjpa.datacache.DelegatingQueryCache
- All Implemented Interfaces:
QueryCache,TypesChangedListener,Closeable
Delegating query cache that can also perform exception translation for
use in facades. This cache allows its delegate to be null, in which case
it returns default values or all methods.
- Since:
- 0.4.0
- Author:
- Abe White
-
Constructor Summary
ConstructorsConstructorDescriptionDelegatingQueryCache(QueryCache cache) Constructor.DelegatingQueryCache(QueryCache cache, RuntimeExceptionTranslator trans) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a new types event listener to this cache.voidclear()Remove all data from this cache.voidclose()Free the resources used by this cache.booleanReturn a list of oids for the given query key.Return the direct delegate.Return the native delegate.Gets the simple statistics for query results.inthashCode()voidInitialize any resources associated with the givenDataCacheManager.voidNotification that instances of persistent types have changed.booleanPin the value stored underqkinto the cache.put(QueryKey qk, QueryResult oids) Set the list of OIDs for the given query key.Remove the value stored under the given query key.booleanRemove an types event listener from this cache.protected RuntimeExceptionTranslate the OpenJPA exception.booleanUnpin the value stored underkeyinto the cache.voidObtain a write lock on the cache.voidRelease the write lock on the cache.
-
Constructor Details
-
DelegatingQueryCache
Constructor. Supply delegate. -
DelegatingQueryCache
-
-
Method Details
-
getDelegate
Return the direct delegate. -
getInnermostDelegate
Return the native delegate. -
hashCode
public int hashCode() -
equals
-
translate
Translate the OpenJPA exception. -
initialize
Description copied from interface:QueryCacheInitialize any resources associated with the givenDataCacheManager.- Specified by:
initializein interfaceQueryCache
-
onTypesChanged
Description copied from interface:TypesChangedListenerNotification that instances of persistent types have changed.- Specified by:
onTypesChangedin interfaceTypesChangedListener
-
get
Description copied from interface:QueryCacheReturn a list of oids for the given query key. This is an unmodifiable list.- Specified by:
getin interfaceQueryCache- Returns:
- The query results matching the given key, or null if none
-
put
Description copied from interface:QueryCacheSet the list of OIDs for the given query key. A reference to the given list will be stored in the query cache, so the list should not be modified after invoking this method.- Specified by:
putin interfaceQueryCache- Returns:
- The previously cached value, or
nullif the key was not previously cached. SeeMap.put(K, V)for more information.
-
remove
Description copied from interface:QueryCacheRemove the value stored under the given query key. This method is typically not invoked directly from outside theQueryCacheclass. Instead, the cache should be updated by implementingRemoteCommitListener, which will result in all queries that may be invalid being dropped.- Specified by:
removein interfaceQueryCache- Returns:
- The previously cached value, or
nullif the key was not previously cached. SeeMap.remove(java.lang.Object)for more information.
-
clear
public void clear()Description copied from interface:QueryCacheRemove all data from this cache.- Specified by:
clearin interfaceQueryCache
-
pin
Description copied from interface:QueryCachePin the value stored underqkinto the cache. This method guarantees thatqk's value will not be expired if the cache exceeds its capacity. It causes this data to be ignored when determining whether or not the cache is full, effectively increasing the total amount of data stored in the cache. This method does not affect the behavior ofQueryCache.remove(org.apache.openjpa.datacache.QueryKey)orTypesChangedListener.onTypesChanged(org.apache.openjpa.datacache.TypesChangedEvent).- Specified by:
pinin interfaceQueryCache- Returns:
trueifkey's value was pinned into the cache;falseif the key is not in the cache.
-
unpin
Description copied from interface:QueryCacheUnpin the value stored underkeyinto the cache. This method reverses a previous invocation ofQueryCache.pin(org.apache.openjpa.datacache.QueryKey). This method does not remove anything from the cache; it merely makeskey's value a candidate for flushing from the cache.- Specified by:
unpinin interfaceQueryCache- Returns:
trueifkey's value was unpinned from the cache;falseif the key is not in the cache.
-
writeLock
public void writeLock()Description copied from interface:QueryCacheObtain a write lock on the cache.- Specified by:
writeLockin interfaceQueryCache
-
writeUnlock
public void writeUnlock()Description copied from interface:QueryCacheRelease the write lock on the cache.- Specified by:
writeUnlockin interfaceQueryCache
-
addTypesChangedListener
Description copied from interface:QueryCacheAdd a new types event listener to this cache.- Specified by:
addTypesChangedListenerin interfaceQueryCache
-
removeTypesChangedListener
Description copied from interface:QueryCacheRemove an types event listener from this cache.- Specified by:
removeTypesChangedListenerin interfaceQueryCache
-
close
public void close()Description copied from interface:QueryCacheFree the resources used by this cache.- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceQueryCache
-
getStatistics
Description copied from interface:QueryCacheGets the simple statistics for query results. If the statistics gathering is disabled, an empty statistics is returned.- Specified by:
getStatisticsin interfaceQueryCache
-