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 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 Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
commit()
Commit the transaction.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:
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;
-
-