org.apache.commons.transaction
Interface Transaction

All Known Implementing Classes:
DefaultTransaction

public interface Transaction

A managed transaction meant as interface to the user.

Should be used to combine multiple resource managers into a complex transaction. Once a resource manager has joined such a complex transaction all transactional control is performed by this transaction. Do not call transactional methods on the resource managers directly.

This is a light weight replacement for a complex 2PC xa transaction.

See Also:
DefaultTransaction

Method Summary
 void commit()
          Commits the complex transaction meaning that all changes made to participating resource managers are made permanent.
 void enlistResourceManager(ManageableResourceManager resourceManager)
          Adds a resource manager to this complex transaction.
 boolean isRollbackOnly()
          Checks whether this transaction allows a rollback as the only valid outcome.
 void rollback()
          Rolls back the complex transaction meaning that all changes made to participating resource managers are undone.
 void start(long timeout, TimeUnit unit)
          Starts a new transactions having a specific timeout.
 

Method Detail

start

void start(long timeout,
           TimeUnit unit)
Starts a new transactions having a specific timeout. You can add resource managers before start or afterwards.

Parameters:
timeout - the maximum time this transaction can run before it times out
unit - the time unit of the timeout argument

isRollbackOnly

boolean isRollbackOnly()
Checks whether this transaction allows a rollback as the only valid outcome. Once a transaction is marked for rollback there is no way to undo this. A transaction that is marked for rollback can not be committed.

Returns:
true if this transaction can only rolled back

rollback

void rollback()
Rolls back the complex transaction meaning that all changes made to participating resource managers are undone.


commit

void commit()
Commits the complex transaction meaning that all changes made to participating resource managers are made permanent.


enlistResourceManager

void enlistResourceManager(ManageableResourceManager resourceManager)
Adds a resource manager to this complex transaction. This means the resource manager will from now on be controlled by this transaction. Access to transactional methods is not allowed until the complex transaction has finished. Of course, it is legal to call the other methods if this manager to perform some real work.

Parameters:
resourceManager - the resource manager to add


Copyright © 2004-2007 The Apache Software Foundation. All Rights Reserved.