Package org.apache.openjpa.jdbc.kernel
Class FinderCacheImpl
java.lang.Object
org.apache.openjpa.jdbc.kernel.FinderCacheImpl
- All Implemented Interfaces:
FinderCache<ClassMapping,,SelectExecutor, Result> Configurable
public class FinderCacheImpl
extends Object
implements FinderCache<ClassMapping,SelectExecutor,Result>
Implementation of FinderCache for JDBC.
- Since:
- 2.0.0
- Author:
- Pinaki Poddar
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExclusionPattern(String pattern) Adds a pattern for exclusion.cache(ClassMapping mapping, SelectExecutor select, FetchConfiguration fetch) Cache a Finder Query for the given mapping and select.voidInvoked upon completion of bean property configuration for this object.get(ClassMapping mapping, FetchConfiguration fetch) Gets the finder query for the given mapping.booleanGets the excluded stringified keys.Get a map-oriented view of the cache.Gets basic statistics of execution and hit count of finder queries.booleaninvalidate(ClassMapping mapping) Remove the FinderQuery for the given key from this cache.booleanisExcluded(ClassMapping mapping) Affirms if the given mapping is excluded from being cached.markUncachable(String id) markUncachable(ClassMapping mapping) Marks the given key as not amenable to caching.voidremoveExclusionPattern(String pattern) Removes a pattern for exclusion.voidInvoked prior to setting bean properties.voidsetEnableStats(boolean b) voidsetExcludes(String excludes) voidInvoked before bean property configuration is begun on this object.
-
Constructor Details
-
FinderCacheImpl
public FinderCacheImpl()
-
-
Method Details
-
getMapView
Get a map-oriented view of the cache.- Specified by:
getMapViewin interfaceFinderCache<ClassMapping,SelectExecutor, Result> - Returns:
- a map of the query string with class names as key.
-
getStatistics
Gets basic statistics of execution and hit count of finder queries.- Specified by:
getStatisticsin interfaceFinderCache<ClassMapping,SelectExecutor, Result>
-
get
public FinderQuery<ClassMapping,SelectExecutor, getResult> (ClassMapping mapping, FetchConfiguration fetch) Gets the finder query for the given mapping. The get operation can be controlled by FetchConfiguration hints.HINT_IGNORE_FINDERwill ignore any cached finder that may exist in this cache and will return null.HINT_INVALIDATE_FINDERwill invalidate any cached finder that may exist in this cache and will return null.- Specified by:
getin interfaceFinderCache<ClassMapping,SelectExecutor, Result> - Parameters:
mapping- for which the finder is looked up- Returns:
- FinderQuery for the given mapping.
-
cache
public FinderQuery<ClassMapping,SelectExecutor, cacheResult> (ClassMapping mapping, SelectExecutor select, FetchConfiguration fetch) Cache a Finder Query for the given mapping and select. The put operation can be controlled by FetchConfiguration hints. If no entry exists for the given mapping then an attempt is made to create a new FinderQuery. The attempt, however, may not be successful because all Selects can not be cached.- Specified by:
cachein interfaceFinderCache<ClassMapping,SelectExecutor, Result> - Parameters:
mapping- the class for which the finder is to be cachedselect- the finder queryfetch- may contain hints to control cache operation- Returns:
- the finder query that has been cached. It may be newly constructed or an existing query. If the given key-value can not be cached, then return null.
-
isExcluded
Affirms if the given mapping is excluded from being cached.- Specified by:
isExcludedin interfaceFinderCache<ClassMapping,SelectExecutor, Result>
-
addExclusionPattern
Adds a pattern for exclusion. Any cached finder whose class name matches the given pattern will be marked invalidated as a side-effect.- Specified by:
addExclusionPatternin interfaceFinderCache<ClassMapping,SelectExecutor, Result>
-
removeExclusionPattern
Removes a pattern for exclusion. Any query identifier marked as not cachable due to the given pattern will now be removed from the list of uncachables as a side-effect.- Specified by:
removeExclusionPatternin interfaceFinderCache<ClassMapping,SelectExecutor, Result>
-
invalidate
Description copied from interface:FinderCacheRemove the FinderQuery for the given key from this cache.- Specified by:
invalidatein interfaceFinderCache<ClassMapping,SelectExecutor, Result>
-
markUncachable
Description copied from interface:FinderCacheMarks the given key as not amenable to caching. Explicit marking helps to avoid repeated computational cost of determining whether finder for a key can be cached or not. Explicit marking can not be reversed by removal of exclusion patterns.- Specified by:
markUncachablein interfaceFinderCache<ClassMapping,SelectExecutor, Result> - Returns:
- finder query for the given class if it had been cached before. null otherwise.
-
markUncachable
-
setExcludes
-
getExcludes
Description copied from interface:FinderCacheGets the excluded stringified keys.- Specified by:
getExcludesin interfaceFinderCache<ClassMapping,SelectExecutor, Result>
-
setEnableStats
public void setEnableStats(boolean b) -
getEnableStats
public boolean getEnableStats() -
startConfiguration
public void startConfiguration()Description copied from interface:ConfigurableInvoked before bean property configuration is begun on this object.- Specified by:
startConfigurationin interfaceConfigurable
-
setConfiguration
Description copied from interface:ConfigurableInvoked prior to setting bean properties.- Specified by:
setConfigurationin interfaceConfigurable
-
endConfiguration
public void endConfiguration()Description copied from interface:ConfigurableInvoked upon completion of bean property configuration for this object.- Specified by:
endConfigurationin interfaceConfigurable
-