net.sourceforge.esw.collection
Class AggregateTransactionManager

java.lang.Object
  |
  +--net.sourceforge.esw.collection.AggregateTransactionManager

public class AggregateTransactionManager
extends java.lang.Object

Aggregates a Transaction across multiple IMetaCollection instances.

Allows multiple get or put method invocations to be combined into one aggregate transaction. After adding one or more IMetaCollection instances that contain an instance of an ITransactionalTransducter to this AggregateTransactionManager, calling execute on this AggregateTransactionManager instance will invoke those methods on the contained IMetaCollection instances. Once all of the get or put method invocations complete, the commit method will be called on those ITransactionalTransducer instances. If any TransducerExceptions are thrown, then this AggregateTransactionManager will rollback all of its previous get or put method invocations.


Field Summary
protected  boolean bStrict
          States whether this AggregateTransactionManager should enforce that all IMetaCollection instances added to manager must contain an ITransactionalTransducer instance as its ITransducer.
protected  java.util.List collections
          The List of IMetaCollection instances.
protected  java.util.List operations
          The operation to perform against the List of IMetaCollection instances.
 
Constructor Summary
AggregateTransactionManager()
          Creates a new AggregateTransactionManager.
AggregateTransactionManager(boolean aStrict)
          Creates a new AggregateTransactionManager which allows enforcement of all IMetaCollection instances to contain an ITransactionalTransducer as their ITransducer instance.
 
Method Summary
 void addMetaCollection(IMetaCollection aMetaCollection, boolean aGet)
          Adds the specified IMetaCollection instance to this AggregateTransactionManager instance.
 void execute()
          Begins the execution against this AggregateTransactionManager instances' collection of IMetaCollection instances.
 boolean getEnforceTransactional()
          Returns whether this AggregateTransactionManager should enforce that all IMetaCollection instances added to manager must contain an ITransactionalTransducer instance as its ITransducer.
 void removeMetaCollection(IMetaCollection aMetaCollection)
          Removes the specified IMetaCollection instance from this AggregateTransactionManager instance.
 void setEnforceTransactional(boolean aStrict)
          Sets whether this AggregateTransactionManager should enforce that all IMetaCollection instances added to this manager must contain an ITransactionalTransducer instance as its ITransducer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

collections

protected java.util.List collections
The List of IMetaCollection instances.

operations

protected java.util.List operations
The operation to perform against the List of IMetaCollection instances.

bStrict

protected boolean bStrict
States whether this AggregateTransactionManager should enforce that all IMetaCollection instances added to manager must contain an ITransactionalTransducer instance as its ITransducer. The default is false.
Constructor Detail

AggregateTransactionManager

public AggregateTransactionManager()
Creates a new AggregateTransactionManager.

AggregateTransactionManager

public AggregateTransactionManager(boolean aStrict)
Creates a new AggregateTransactionManager which allows enforcement of all IMetaCollection instances to contain an ITransactionalTransducer as their ITransducer instance.
Parameters:
aStrict - if true, this AggregateTransactionManager will enforce Transactional Transducers against added IMetaCollection instances.
Method Detail

getEnforceTransactional

public boolean getEnforceTransactional()
Returns whether this AggregateTransactionManager should enforce that all IMetaCollection instances added to manager must contain an ITransactionalTransducer instance as its ITransducer.
Returns:
true if enforcing Transaction Transducers, false otherwise.

setEnforceTransactional

public void setEnforceTransactional(boolean aStrict)
Sets whether this AggregateTransactionManager should enforce that all IMetaCollection instances added to this manager must contain an ITransactionalTransducer instance as its ITransducer. If changing to enforce Transactional Transducer, this method will also check to see if the IMetaCollection instances contained within this AggregateTransactionManager contain ITransactionalTransducer instances and will throw an IllegalArguementException if so.
Parameters:
aStrict - if true, this AggregateTransactionManager will enforce Transactional Transducers against added IMetaCollection instances.
Throws:
java.lang.IllegalArgumentException - if any contained IMetaCollection instances contain ITransactionTransducer instances.

addMetaCollection

public void addMetaCollection(IMetaCollection aMetaCollection,
                              boolean aGet)
Adds the specified IMetaCollection instance to this AggregateTransactionManager instance. The IMetaCollection must contain an instance of an ITransactionalTransducer or an IllegalArguementException will be thrown.
Parameters:
aMetaCollection - the IMetaCollection instance being added.
aGet - states whether the transaction to preform is a get or a put against the specified IMetaCollection instance.
Throws:
java.lang.IllegalArgumentException - if the IMetaCollection instance does not contain an ITransactionalTranducer.

removeMetaCollection

public void removeMetaCollection(IMetaCollection aMetaCollection)
Removes the specified IMetaCollection instance from this AggregateTransactionManager instance.
Parameters:
aMetaCollection - the IMetaCollection instance being removed.

execute

public void execute()
             throws TransducerException
Begins the execution against this AggregateTransactionManager instances' collection of IMetaCollection instances.

If all the transducer invocations are successful, then the IMetaCollection instances containing ITransactionalTransducer instances' commit will be invoked. However, if any TransducerExceptions are thrown, then rollback will be called on those same ITransactionalTransducer instances.

Throws:
TransducerException - if the execution fails.


Copyright 2002 Free Software Foundation. All Rights Reserved.