Package de.uplanet.util.transaction
Interface ITwoPhaseTransaction
- All Known Subinterfaces:
ITwoPhaseIOTransaction
- All Known Implementing Classes:
AbstractTwoPhaseIOTransaction
,DirectDirectoryCreateTransaction
,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() }
-
Method Details
-
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:
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:
true
if the rollback was successful, orfalse
otherwise. 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
null
if no error occurred;
-