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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addExclusionPattern
(String pattern) Adds a pattern for exclusion.cache
(ClassMapping mapping, SelectExecutor select, FetchConfiguration fetch) Cache a Finder Query for the given mapping and select.void
Invoked upon completion of bean property configuration for this object.get
(ClassMapping mapping, FetchConfiguration fetch) Gets the finder query for the given mapping.boolean
Gets the excluded stringified keys.Get a map-oriented view of the cache.Gets basic statistics of execution and hit count of finder queries.boolean
invalidate
(ClassMapping mapping) Remove the FinderQuery for the given key from this cache.boolean
isExcluded
(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.void
removeExclusionPattern
(String pattern) Removes a pattern for exclusion.void
Invoked prior to setting bean properties.void
setEnableStats
(boolean b) void
setExcludes
(String excludes) void
Invoked 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:
getMapView
in 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:
getStatistics
in 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_FINDER
will ignore any cached finder that may exist in this cache and will return null.HINT_INVALIDATE_FINDER
will invalidate any cached finder that may exist in this cache and will return null.- Specified by:
get
in 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:
cache
in 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:
isExcluded
in 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:
addExclusionPattern
in 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:
removeExclusionPattern
in interfaceFinderCache<ClassMapping,
SelectExecutor, Result>
-
invalidate
Description copied from interface:FinderCache
Remove the FinderQuery for the given key from this cache.- Specified by:
invalidate
in interfaceFinderCache<ClassMapping,
SelectExecutor, Result>
-
markUncachable
Description copied from interface:FinderCache
Marks 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:
markUncachable
in 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:FinderCache
Gets the excluded stringified keys.- Specified by:
getExcludes
in interfaceFinderCache<ClassMapping,
SelectExecutor, Result>
-
setEnableStats
public void setEnableStats(boolean b) -
getEnableStats
public boolean getEnableStats() -
startConfiguration
public void startConfiguration()Description copied from interface:Configurable
Invoked before bean property configuration is begun on this object.- Specified by:
startConfiguration
in interfaceConfigurable
-
setConfiguration
Description copied from interface:Configurable
Invoked prior to setting bean properties.- Specified by:
setConfiguration
in interfaceConfigurable
-
endConfiguration
public void endConfiguration()Description copied from interface:Configurable
Invoked upon completion of bean property configuration for this object.- Specified by:
endConfiguration
in interfaceConfigurable
-