|
Framework Professional Edition Package |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.mbs.services.transaction.file.FileTransactionResource
public abstract class FileTransactionResource
The FileTransactionResource is an utility class, that is used by resources that deals with files. Before performing a file operation, the caller should mark the file with the correct operation. The marked files will be correctly restored on rollback. However, this requires that the extending class calls the mark() method before any file operation, and calls the super commit() and rollback() methods. Notice, that this implementation is not thread-safe and if the developer performs operation though different threads, should also synchronize the calls.
| Field Summary | |
|---|---|
static int |
FILE_CREATE
Marks the file is newly (or will be) created. |
static int |
FILE_CREATE_TEMP
Marks that a newly temporary file is/will be created. |
static int |
FILE_MODIFY
Marks the file as being modified, this takes a snapshot of the file, that is restored on rollback. |
static int |
FILE_REMOVE
Not only marks the file as removed, but also deletes it. |
static java.lang.String |
FILE_TRANSACTION_PROP
Use this system property to replace the default FileTransaction
implementation. |
protected TransactionManager |
transactionManager
This is the transaction manager instance. |
| Constructor Summary | |
|---|---|
FileTransactionResource()
|
|
| Method Summary | |
|---|---|
void |
commit(TransactionContext transaction)
Commit all the changes associated with the given transaction. |
protected void |
mark(int operation,
java.io.File file)
Marks a file, that operation is being performed on it. |
protected FileTransaction |
newFileTransaction()
Override this method in order to use different implementation of FileTransaciton. |
void |
rollback(TransactionContext transaction)
Undo all the changes made to this subsystem that are associated with the given transaction. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.mbs.services.transaction.TransactionResource |
|---|
prepare |
| Field Detail |
|---|
public static final java.lang.String FILE_TRANSACTION_PROP
FileTransaction
implementation. The name of the property is
"mbs.transactions.file.impl.class".
public static final int FILE_REMOVE
public static final int FILE_CREATE
public static final int FILE_CREATE_TEMP
public static final int FILE_MODIFY
protected TransactionManager transactionManager
| Constructor Detail |
|---|
public FileTransactionResource()
| Method Detail |
|---|
public void commit(TransactionContext transaction)
TransactionResource
commit in interface TransactionResourceTransactionResource.commit(org.mbs.services.transaction.TransactionContext)public void rollback(TransactionContext transaction)
TransactionResource
rollback in interface TransactionResourcetransaction - The associated transaction.TransactionResource.rollback(org.mbs.services.transaction.TransactionContext)
protected void mark(int operation,
java.io.File file)
throws java.io.IOException
operation - the operation that will be performed on the file.file - the file itself.
java.io.IOException - on I/O errorprotected FileTransaction newFileTransaction()
FileTransaction implementation, if the
FILE_TRANSACTION_PROP system property is set. Otherwise the
default FileTransactionPlain implementation is used.
|
Framework Professional Edition Package |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||