This is what its developers wrote:
We have decided to move the project to dormant as we are convinced that the main advertised feature transactional file access can not be implemented reliably. We are convinced that no such implementation can be possible on top of an ordinary file system. Although there are other useful parts (as multi level locking including deadlock detection) the transactional file system is the main reason people use this library for. As it simply can not be made fully transactional, it does not work as advertised.
The optimal - but maybe impudent - long term goal would be to create the transactional counterpart of Doug Lea's fabulous concurrent package which recently made it to Java 5.0.
... when you have to conduct concurrent file operations like updating files while other threads might read them. After initializing org.apache.commons.transaction.file.FileResourceManager
it is as easy as this:
String txId = manager.generatedUniqueTxId()
manager.startTransaction(txId);
OutputStream out = manager.writeResource(txId, "path/to/file");
// write to out. No need to close the stream.
manager.commitTransaction(txId);
While the write goes on, other threads can still read the file concurrently. Only when the "transaction" is committed, the original file is replaced by the newly written one, what is much faster than locking the original file for the time of the write.
To make this work, every thread has to access the files through the same FileResourceManager instance:
String txId = manager.generatedUniqueTxId()
manager.startTransaction(txId);
manager.setIsolationLevel(txId, ResourceManager.ISOLATION_LEVEL_READ_COMMITTED);
InputStream inputStream = manager.readResource(txId, "path/to/file");
// read the inputStream. No need to close the stream.
manager.commitTransaction(txId);
<dependency>
<groupId>commons-transaction</groupId>
<artifactId>commons-transaction</artifactId>
<version>1.2</version>
</dependency>