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 java.lang.Object implements FinderCache<ClassMapping,SelectExecutor,Result>
Implementation of FinderCache for JDBC.- Since:
- 2.0.0
- Author:
- Pinaki Poddar
-
-
Constructor Summary
Constructors Constructor Description FinderCacheImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addExclusionPattern(java.lang.String pattern)
Adds a pattern for exclusion.FinderQuery<ClassMapping,SelectExecutor,Result>
cache(ClassMapping mapping, SelectExecutor select, FetchConfiguration fetch)
Cache a Finder Query for the given mapping and select.void
endConfiguration()
Invoked upon completion of bean property configuration for this object.FinderQuery<ClassMapping,SelectExecutor,Result>
get(ClassMapping mapping, FetchConfiguration fetch)
Gets the finder query for the given mapping.boolean
getEnableStats()
java.util.List<java.lang.String>
getExcludes()
Gets the excluded stringified keys.java.util.Map<java.lang.String,java.lang.String>
getMapView()
Get a map-oriented view of the cache.QueryStatistics<ClassMapping>
getStatistics()
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.FinderQuery<ClassMapping,SelectExecutor,Result>
markUncachable(java.lang.String id)
FinderQuery<ClassMapping,SelectExecutor,Result>
markUncachable(ClassMapping mapping)
Marks the given key as not amenable to caching.void
removeExclusionPattern(java.lang.String pattern)
Removes a pattern for exclusion.void
setConfiguration(Configuration conf)
Invoked prior to setting bean properties.void
setEnableStats(boolean b)
void
setExcludes(java.lang.String excludes)
void
startConfiguration()
Invoked before bean property configuration is begun on this object.
-
-
-
Method Detail
-
getMapView
public java.util.Map<java.lang.String,java.lang.String> 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
public QueryStatistics<ClassMapping> 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,Result> get(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,Result> cache(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
public boolean isExcluded(ClassMapping mapping)
Affirms if the given mapping is excluded from being cached.- Specified by:
isExcluded
in interfaceFinderCache<ClassMapping,SelectExecutor,Result>
-
addExclusionPattern
public void addExclusionPattern(java.lang.String pattern)
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
public void removeExclusionPattern(java.lang.String pattern)
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
public boolean invalidate(ClassMapping mapping)
Description copied from interface:FinderCache
Remove the FinderQuery for the given key from this cache.- Specified by:
invalidate
in interfaceFinderCache<ClassMapping,SelectExecutor,Result>
-
markUncachable
public FinderQuery<ClassMapping,SelectExecutor,Result> markUncachable(ClassMapping mapping)
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
public FinderQuery<ClassMapping,SelectExecutor,Result> markUncachable(java.lang.String id)
-
setExcludes
public void setExcludes(java.lang.String excludes)
-
getExcludes
public java.util.List<java.lang.String> 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
public void setConfiguration(Configuration conf)
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
-
-