de.uplanet.util.transaction
Interface ITwoPhaseTransaction

All Known Subinterfaces:
ITwoPhaseIOTransaction
All Known Implementing Classes:
DirectDirectoryDeleteTransaction, DirectDirectoryTransaction, DirectFileCopyTransaction, DirectFileDeleteTransaction, DirectFileMoveTransaction, IndirectDeleteDirectoryTransaction, IndirectDeleteFileTransaction, IndirectDirectoryCreateTransaction, IndirectDirectoryTransaction, IndirectFileCopyTransaction, IndirectFileCreateFileTransaction, IndirectFileMoveTransaction, IxFileUploadTransaction

public interface ITwoPhaseTransaction

A simple two-phase commit file system transaction.

The basic usage pattern is:

  for each ISimpleFileSystemTransaction cohort
      allGood = allGood && cohort.requestCommit()

  if allGood
  {
      for each ISimpleFileSystemTransaction cohort
          cohort.commit()
  }
  else
  {
      for each ISimpleFileSystemTransaction cohort
          cohort.rollback()
  }
 

Version:
$Revision: 74059 $

Method Summary
 void commit()
          Commit the transaction.
 java.lang.Throwable getLastError()
           
 boolean requestCommit()
          Request a file system transaction.
 boolean rollback()
          Try to rollback the file system transaction.
 

Method Detail

requestCommit

boolean requestCommit()
Request a file system transaction.

When this method returns true it has sucessfully moved the source file to it's new location, and has successfully created a backup copy of the destination file, if it existed before.

Throws:
java.lang.IllegalStateException - If the two-phase commit protocol was violated.

commit

void commit()
Commit the transaction.

Throws:
java.lang.IllegalStateException - If the two-phase commit protocol was violated.

rollback

boolean rollback()
Try to rollback the file system transaction.

Returns:
true if the rollback was successful, or false otherwise. In the latter case getLastError() may give additional information about why the rollback failed. A backup may exist then.
Throws:
java.lang.IllegalStateException - If the two-phase commit protocol was violated.

getLastError

java.lang.Throwable getLastError()
Returns:
The last exception that was caugth during the transaction, or null if no error occurred;


Last updated: 2011-08-11 10-04
Copyright © 2000-2011 United Planet. All Rights Reserved.