org.jasig.services.persondir.support
Class CachingPersonAttributeDaoImpl

java.lang.Object
  extended by org.jasig.services.persondir.support.AbstractFlatteningPersonAttributeDao
      extended by org.jasig.services.persondir.support.AbstractDefaultAttributePersonAttributeDao
          extended by org.jasig.services.persondir.support.CachingPersonAttributeDaoImpl
All Implemented Interfaces:
org.jasig.services.persondir.IPersonAttributeDao, InitializingBean

public class CachingPersonAttributeDaoImpl
extends AbstractDefaultAttributePersonAttributeDao
implements InitializingBean

A configurable caching implementation of IPersonAttributeDao which caches results from a wrapped IPersonAttributeDao.

Configuration:

Property Description Required Default
cachedPersonAttributesDao The IPersonAttributeDao to delegate queries to on cache misses. Yes null
userInfoCache The Map to use for result caching. This class does no cache maintenence. It is assumed the underlying Map implementation will ensure the cache is in a good state at all times. Yes null
cacheKeyAttributes A Set of attribute names to use when building the cache key. The default implementation generates the key as a Map of attributeNames to values retrieved from the seed for the query. Zero length sets are treaded as null. No null
cacheNullResults If the wrapped IPersonAttributeDao returns null for the query should that null value be stored in the cache. No false
nullResultsObject If cacheNullResults is set to true this value is stored in the cache for any query that returns null. This is used as a flag so the same query will return null from the cache by seeing this value No NULL_RESULTS_OBJECT

Version:
$Id
Author:
dgrimwood@unicon.net, Eric Dalquist

Field Summary
protected static Map<String,List<Object>> NULL_RESULTS_OBJECT
           
protected  Log statsLogger
           
 
Fields inherited from class org.jasig.services.persondir.support.AbstractFlatteningPersonAttributeDao
logger
 
Constructor Summary
CachingPersonAttributeDaoImpl()
           
 
Method Summary
 void afterPropertiesSet()
           
 org.jasig.services.persondir.IPersonAttributeDao getCachedPersonAttributesDao()
           
 Set<String> getCacheKeyAttributes()
          Deprecated. these should be retrieved from the provided CacheKeyGenerator if applicable
 long getMisses()
           
 Map<String,List<Object>> getMultivaluedUserAttributes(Map<String,List<Object>> seed)
          Wraps the call to the specified cachedPersonAttributesDao IPersonAttributeDao delegate with a caching layer.
 Map<String,List<Object>> getNullResultsObject()
           
 Set<String> getPossibleUserAttributeNames()
           
 long getQueries()
           
 Map<Serializable,Map<String,List<Object>>> getUserInfoCache()
           
 boolean isCacheNullResults()
           
 void setCachedPersonAttributesDao(org.jasig.services.persondir.IPersonAttributeDao cachedPersonAttributesDao)
           
 void setCacheKeyAttributes(Set<String> cacheKeyAttributes)
          Deprecated. these should be set on the provided CacheKeyGenerator if applicable
 void setCacheNullResults(boolean cacheNullResults)
           
 void setNullResultsObject(Map<String,List<Object>> nullResultsObject)
           
 void setUserInfoCache(Map<Serializable,Map<String,List<Object>>> userInfoCache)
           
 
Methods inherited from class org.jasig.services.persondir.support.AbstractDefaultAttributePersonAttributeDao
getDefaultAttributeName, getMultivaluedUserAttributes, setDefaultAttributeName
 
Methods inherited from class org.jasig.services.persondir.support.AbstractFlatteningPersonAttributeDao
flattenResults, getUserAttributes, getUserAttributes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_RESULTS_OBJECT

protected static final Map<String,List<Object>> NULL_RESULTS_OBJECT

statsLogger

protected Log statsLogger
Constructor Detail

CachingPersonAttributeDaoImpl

public CachingPersonAttributeDaoImpl()
Method Detail

getCachedPersonAttributesDao

public org.jasig.services.persondir.IPersonAttributeDao getCachedPersonAttributesDao()
Returns:
Returns the cachedPersonAttributesDao.

setCachedPersonAttributesDao

public void setCachedPersonAttributesDao(org.jasig.services.persondir.IPersonAttributeDao cachedPersonAttributesDao)
Parameters:
cachedPersonAttributesDao - The cachedPersonAttributesDao to set.

getCacheKeyAttributes

@Deprecated
public Set<String> getCacheKeyAttributes()
Deprecated. these should be retrieved from the provided CacheKeyGenerator if applicable

Returns:
Returns the cacheKeyAttributes.

setCacheKeyAttributes

@Deprecated
public void setCacheKeyAttributes(Set<String> cacheKeyAttributes)
Deprecated. these should be set on the provided CacheKeyGenerator if applicable

Parameters:
cacheKeyAttributes - The cacheKeyAttributes to set.

getUserInfoCache

public Map<Serializable,Map<String,List<Object>>> getUserInfoCache()
Returns:
Returns the userInfoCache.

setUserInfoCache

public void setUserInfoCache(Map<Serializable,Map<String,List<Object>>> userInfoCache)
Parameters:
userInfoCache - The userInfoCache to set.

isCacheNullResults

public boolean isCacheNullResults()
Returns:
the cacheNullResults

setCacheNullResults

public void setCacheNullResults(boolean cacheNullResults)
Parameters:
cacheNullResults - the cacheNullResults to set

getNullResultsObject

public Map<String,List<Object>> getNullResultsObject()
Returns:
the nullResultsObject

setNullResultsObject

public void setNullResultsObject(Map<String,List<Object>> nullResultsObject)
Parameters:
nullResultsObject - the nullResultsObject to set

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

getMisses

public long getMisses()
Returns:
Returns the number of cache misses.

getQueries

public long getQueries()
Returns:
Returns the number of queries.

getMultivaluedUserAttributes

public Map<String,List<Object>> getMultivaluedUserAttributes(Map<String,List<Object>> seed)
Wraps the call to the specified cachedPersonAttributesDao IPersonAttributeDao delegate with a caching layer. Results are cached using keys generated by #getCacheKey(Map).

Specified by:
getMultivaluedUserAttributes in interface org.jasig.services.persondir.IPersonAttributeDao
See Also:
IPersonAttributeDao.getUserAttributes(java.util.Map)

getPossibleUserAttributeNames

public Set<String> getPossibleUserAttributeNames()
Specified by:
getPossibleUserAttributeNames in interface org.jasig.services.persondir.IPersonAttributeDao
See Also:
IPersonAttributeDao.getPossibleUserAttributeNames()


Copyright © 1998-2008 Java Architectures Special Interest Group. All Rights Reserved.