org.apache.openjpa.jdbc.kernel
Class FinderCacheImpl

java.lang.Object
  extended by 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
FinderCacheImpl()
           
 
Method Summary
 void addExclusionPattern(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()
           
 FinderQuery<ClassMapping,SelectExecutor,Result> get(ClassMapping mapping, FetchConfiguration fetch)
          Gets the finder query for the given mapping.
 boolean getEnableStats()
           
 List<String> getExcludes()
           
 Map<String,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)
           
 boolean isExcluded(ClassMapping mapping)
          Affirms if the given mapping is excluded from being cached.
(package private)  boolean isHinted(FetchConfiguration fetch, String hint)
           
(package private)  void lock()
           
 FinderQuery<ClassMapping,SelectExecutor,Result> markUncachable(ClassMapping mapping)
           
 FinderQuery<ClassMapping,SelectExecutor,Result> markUncachable(String id)
           
(package private)  boolean matches(String pattern, ClassMapping mapping)
           
(package private)  boolean matches(String pattern, String target)
           
 void removeExclusionPattern(String pattern)
          Removes a pattern for exclusion.
(package private)  ClassMapping searchMappingByName(String cls)
           
 void setConfiguration(Configuration conf)
           
 void setEnableStats(boolean b)
           
 void setExcludes(String excludes)
           
 void startConfiguration()
           
(package private)  void unlock()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FinderCacheImpl

public FinderCacheImpl()
Method Detail

getMapView

public Map<String,String> getMapView()
Get a map-oriented view of the cache.

Specified by:
getMapView in interface FinderCache<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 interface FinderCache<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 interface FinderCache<ClassMapping,SelectExecutor,Result>

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 interface FinderCache<ClassMapping,SelectExecutor,Result>
Parameters:
mapping - the class for which the finder is to be cached
select - the finder query
fetch - may contain hints to control cache operation
See Also:
If a entry for the given mapping exists then the value of {@link QueryHints#HINT_RECACHE_FINDER HINT_RECACHE_FINDER} hint determines whether the existing entry is returned or a new FinderQuery with the given argument overwrites the existing one.

isExcluded

public boolean isExcluded(ClassMapping mapping)
Affirms if the given mapping is excluded from being cached.

Specified by:
isExcluded in interface FinderCache<ClassMapping,SelectExecutor,Result>

addExclusionPattern

public void addExclusionPattern(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 interface FinderCache<ClassMapping,SelectExecutor,Result>

removeExclusionPattern

public void removeExclusionPattern(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 interface FinderCache<ClassMapping,SelectExecutor,Result>

matches

boolean matches(String pattern,
                ClassMapping mapping)

matches

boolean matches(String pattern,
                String target)

invalidate

public boolean invalidate(ClassMapping mapping)
Specified by:
invalidate in interface FinderCache<ClassMapping,SelectExecutor,Result>

markUncachable

public FinderQuery<ClassMapping,SelectExecutor,Result> markUncachable(ClassMapping mapping)
Specified by:
markUncachable in interface FinderCache<ClassMapping,SelectExecutor,Result>

markUncachable

public FinderQuery<ClassMapping,SelectExecutor,Result> markUncachable(String id)

searchMappingByName

ClassMapping searchMappingByName(String cls)

setExcludes

public void setExcludes(String excludes)

getExcludes

public List<String> getExcludes()
Specified by:
getExcludes in interface FinderCache<ClassMapping,SelectExecutor,Result>

isHinted

boolean isHinted(FetchConfiguration fetch,
                 String hint)

lock

void lock()

unlock

void unlock()

setEnableStats

public void setEnableStats(boolean b)

getEnableStats

public boolean getEnableStats()

startConfiguration

public void startConfiguration()
Specified by:
startConfiguration in interface Configurable

setConfiguration

public void setConfiguration(Configuration conf)
Specified by:
setConfiguration in interface Configurable

endConfiguration

public void endConfiguration()
Specified by:
endConfiguration in interface Configurable


Copyright © 2006-2013 Apache Software Foundation. All Rights Reserved.