Package de.uplanet.util.transaction
Interface ITwoPhaseTransaction
-
- All Known Subinterfaces:
ITwoPhaseIOTransaction
- All Known Implementing Classes:
DirectDirectoryCreateTransaction,DirectDirectoryDeleteTransaction,DirectDirectoryTransaction,DirectFileCopyTransaction,DirectFileDeleteTransaction,DirectFileMoveTransaction,IndirectDeleteDirectoryTransaction,IndirectDeleteFileTransaction,IndirectDirectoryCreateTransaction,IndirectDirectoryTransaction,IndirectFileCopyTransaction,IndirectFileCreateFileTransaction,IndirectFileMoveTransaction,IxFileUploadTransaction
public interface ITwoPhaseTransactionA 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() }
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcommit()Commit the transaction.ThrowablegetLastError()booleanrequestCommit()Request a file system transaction.booleanrollback()Try to rollback the file system transaction.
-
-
-
Method Detail
-
requestCommit
boolean requestCommit()
Request a file system transaction.When this method returns
trueit 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:
IllegalStateException- If the two-phase commit protocol was violated.
-
commit
void commit()
Commit the transaction.- Throws:
IllegalStateException- If the two-phase commit protocol was violated.
-
rollback
boolean rollback()
Try to rollback the file system transaction.- Returns:
trueif the rollback was successful, orfalseotherwise. In the latter casegetLastError()may give additional information about why the rollback failed. A backup may exist then.- Throws:
IllegalStateException- If the two-phase commit protocol was violated.
-
getLastError
Throwable getLastError()
- Returns:
- The last exception that was caugth during the transaction,
or
nullif no error occurred;
-
-