wt.fc
Class WTCollectionRetrySingleProcessor

java.lang.Object
  extended bywt.fc.WTCollectionRetrySingleProcessor
Direct Known Subclasses:
StandardPersistenceManager.AbstractInsertUpdateProcessor

public abstract class WTCollectionRetrySingleProcessor
extends Object

This class implments a Template Method design pattern for executing a multi-object operation such that if it fails with an exception, a new exception can be constructed that will indicate the exact objects that failed. It does this by executing the "same" operation one object at a time and building a list of the objects that fail.

The execute(WTCollection) method executes the multi-object operation, doMultiOperation(WTCollection), in a new Transaction with a savepoint. If an exception is thrown and it is a target of this instance (determine via isTargetExceptionType(Exception), then the Transaction is rolled back to the savepoint (i.e. the datastore state prior to the multi-object operation being executed). Each object is then passed to the doSingleOperation(Persistable)and if the same type of exception occurs, then it is added to a list of failed objects. If an unexpected exception occurs or the list of failed objects is empty, then the original exception is thrown. Otherwise, a new exception is built (via buildNewException(WTCollection)) and thrown by execute(WTCollection).


Field Summary
private  Object attributeState
           
private static String CLASSNAME
           
static boolean DEBUG
           
private static DebugWriter LOG
           
private  Object persistInfoState
           
 
Constructor Summary
protected WTCollectionRetrySingleProcessor()
           
protected WTCollectionRetrySingleProcessor(Object a_persistInfoState, Object a_attributeState)
           
 
Method Summary
protected abstract  WTException buildNewException(WTCollection a_failedObjects)
           
protected abstract  void doMultiOperation(WTCollection a_objects)
           
protected abstract  void doSingleOperation(Persistable a_object)
           
 void execute(WTCollection a_targets)
          This method executes a multi-object operation.
protected abstract  boolean isTargetExceptionType(Exception a_exception)
           
protected  void resetAttributeState(WTCollection a_objects, Object a_state)
           
protected  Object saveAttributeState(WTCollection a_objects)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASSNAME

private static final String CLASSNAME

DEBUG

public static final boolean DEBUG

LOG

private static final DebugWriter LOG

persistInfoState

private Object persistInfoState

attributeState

private Object attributeState
Constructor Detail

WTCollectionRetrySingleProcessor

protected WTCollectionRetrySingleProcessor()

WTCollectionRetrySingleProcessor

protected WTCollectionRetrySingleProcessor(Object a_persistInfoState,
                                           Object a_attributeState)
Method Detail

execute

public void execute(WTCollection a_targets)
             throws WTException
This method executes a multi-object operation.

Throws:
WTException

doMultiOperation

protected abstract void doMultiOperation(WTCollection a_objects)
                                  throws WTException
Throws:
WTException

doSingleOperation

protected abstract void doSingleOperation(Persistable a_object)
                                   throws WTException
Throws:
WTException

isTargetExceptionType

protected abstract boolean isTargetExceptionType(Exception a_exception)

buildNewException

protected abstract WTException buildNewException(WTCollection a_failedObjects)

saveAttributeState

protected Object saveAttributeState(WTCollection a_objects)

resetAttributeState

protected void resetAttributeState(WTCollection a_objects,
                                   Object a_state)