org.jasig.services.persondir.support
Class AbstractAggregatingDefaultQueryPersonAttributeDao

java.lang.Object
  extended by org.jasig.services.persondir.support.AbstractDefaultAttributePersonAttributeDao
      extended by org.jasig.services.persondir.support.AbstractAggregatingDefaultQueryPersonAttributeDao
All Implemented Interfaces:
IPersonAttributeDao
Direct Known Subclasses:
CascadingPersonAttributeDao, MergingPersonAttributeDaoImpl

public abstract class AbstractAggregatingDefaultQueryPersonAttributeDao
extends AbstractDefaultAttributePersonAttributeDao

Provides a base set of implementations and properties for IPersonAttributeDao implementations that aggregate results from a sub List of IPersonAttributeDaos.

Configuration:

Property Description Required Default
personAttributeDaos A List of IPersonAttributeDaos to aggregate attributes from. Yes null
attrMerger A IAttributeMerger strategy to use for merging the attributes from the List of IPersonAttributeDaos. No MultivaluedAttributeMerger
recoverExceptions Sets the action to be taken if one of the IPersonAttributeDaos in the List fails with a RuntimeException. If set to true a warn level log message and stack trace will be logged. If set to false an error level message and stack trace will be logged and the exception will re-thrown. No true

Version:
$Revision: 2892 $
Author:
Eric Dalquist edalquist@unicon.net

Field Summary
protected  IAttributeMerger attrMerger
          Strategy for merging together the results from successive PersonAttributeDaos.
protected  List personAttributeDaos
          A List of child IPersonAttributeDao instances which we will poll in order.
protected  boolean recoverExceptions
          True if we should catch, logger, and ignore Throwables propogated by individual DAOs.
 
Fields inherited from class org.jasig.services.persondir.support.AbstractDefaultAttributePersonAttributeDao
logger
 
Constructor Summary
AbstractAggregatingDefaultQueryPersonAttributeDao()
           
 
Method Summary
protected abstract  Map getAttributesFromDao(Map seed, boolean isFirstQuery, IPersonAttributeDao currentlyConsidering, Map resultAttributes)
          Call to execute the appropriate query on the current IPersonAttributeDao.
 IAttributeMerger getMerger()
          Get the strategy whereby we accumulate attributes.
 List getPersonAttributeDaos()
          Get an unmodifiable List of delegates which we will poll for attributes.
 Set getPossibleUserAttributeNames()
          This implementation is not always correct.
 Map getUserAttributes(Map seed)
          Iterates through the configured List of IPersonAttributeDao instances.
 boolean isRecoverExceptions()
          True if this class will catch exceptions thrown by its delegate DAOs and fail to propogate them.
 void setMerger(IAttributeMerger merger)
          Set the strategy whereby we accumulate attributes from the results of polling our delegates.
 void setPersonAttributeDaos(List daos)
          Set the List of delegates which we will poll for attributes.
 void setRecoverExceptions(boolean recover)
          Set to true if you would like this class to swallow RuntimeExceptions thrown by its delegates.
 
Methods inherited from class org.jasig.services.persondir.support.AbstractDefaultAttributePersonAttributeDao
getDefaultAttributeName, getUserAttributes, setDefaultAttributeName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

personAttributeDaos

protected List personAttributeDaos
A List of child IPersonAttributeDao instances which we will poll in order.


attrMerger

protected IAttributeMerger attrMerger
Strategy for merging together the results from successive PersonAttributeDaos.


recoverExceptions

protected boolean recoverExceptions
True if we should catch, logger, and ignore Throwables propogated by individual DAOs.

Constructor Detail

AbstractAggregatingDefaultQueryPersonAttributeDao

public AbstractAggregatingDefaultQueryPersonAttributeDao()
Method Detail

getUserAttributes

public final Map getUserAttributes(Map seed)
Iterates through the configured List of IPersonAttributeDao instances. The results from each DAO are merged into the result Map by the configured org.jasig.portal.services.persondir.support.merger.IAttributeMerger.

Parameters:
seed - immutable Map of attributes to values to seed the query
Returns:
Map from attribute names to values
See Also:
org.jasig.portal.services.persondir.IPersonAttributeDao#getUserAttributes(java.util.Map)

getAttributesFromDao

protected abstract Map getAttributesFromDao(Map seed,
                                            boolean isFirstQuery,
                                            IPersonAttributeDao currentlyConsidering,
                                            Map resultAttributes)
Call to execute the appropriate query on the current IPersonAttributeDao. Provides extra information beyond the seed for the state of the query chain and previous results.

Parameters:
seed - The seed for the original query.
isFirstQuery - If this is the first query, this will stay true until a call to this method returns (does not throw an exception).
currentlyConsidering - The IPersonAttributeDao to execute the query on.
resultAttributes - The Map of results from all previous queries, may be null.
Returns:
The results from the call to the DAO, follows the same rules as IPersonAttributeDao.getUserAttributes(Map).

getPossibleUserAttributeNames

public Set getPossibleUserAttributeNames()
This implementation is not always correct. It handles the basic case where the Set of attributes returned by this implementation is the union of the attributes declared by all of the underlying implementations to be merged. Of course, an IAttributeMerger might provide for a merging policy such that the attributes resulting from invoking this IPersonAttributeDao implementation are not the union of the attributes declared by the underlying PersonAttributeDaos.

Returns:
A {link Set} of possible attribute names for user queries.
See Also:
org.jasig.portal.services.persondir.IPersonAttributeDao#getPossibleUserAttributeNames()

getMerger

public IAttributeMerger getMerger()
Get the strategy whereby we accumulate attributes.

Returns:
Returns the attrMerger.

setMerger

public void setMerger(IAttributeMerger merger)
Set the strategy whereby we accumulate attributes from the results of polling our delegates.

Parameters:
merger - The attrMerger to set.
Throws:
IllegalArgumentException - If merger is null.

getPersonAttributeDaos

public List getPersonAttributeDaos()
Get an unmodifiable List of delegates which we will poll for attributes.

Returns:
Returns the personAttributeDaos.

setPersonAttributeDaos

public void setPersonAttributeDaos(List daos)
Set the List of delegates which we will poll for attributes.

Parameters:
daos - The personAttributeDaos to set.
Throws:
IllegalArgumentException - If daos is null.

isRecoverExceptions

public boolean isRecoverExceptions()
True if this class will catch exceptions thrown by its delegate DAOs and fail to propogate them. False if this class will stop on failure.

Returns:
true if will recover exceptions, false otherwise

setRecoverExceptions

public void setRecoverExceptions(boolean recover)
Set to true if you would like this class to swallow RuntimeExceptions thrown by its delegates. This allows it to recover if a particular attribute source fails, still considering previous and subsequent sources. Set to false if you would like this class to fail hard upon any Throwable thrown by its children. This is desirable in cases where your Portal will not function without attributes from all of its sources.

Parameters:
recover - whether you would like exceptions recovered internally


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