Prevayler™
The Free Software
Prevalence Layer

org.prevayler.implementation.logging
Class PersistentLogger

java.lang.Object
  extended byorg.prevayler.implementation.logging.PersistentLogger
All Implemented Interfaces:
java.io.FileFilter, TransactionLogger

public class PersistentLogger
extends java.lang.Object
implements java.io.FileFilter, TransactionLogger

A TransactionLogger that will write all transactions to .transactionLog files.


Constructor Summary
PersistentLogger(java.lang.String directory, long logSizeThresholdInBytes, long logAgeThresholdInMillis)
           
 
Method Summary
 boolean accept(java.io.File file)
          Implementing FileFilter. 0000000000000000000.transactionLog is the format of the transaction log filename.
 void close()
           
protected  void handleExceptionWhileCreating(java.io.IOException iox, java.io.File logFile)
           
protected  void handleExceptionWhileWriting(java.io.IOException iox, java.io.File logFile)
           
 void log(Transaction transaction, java.util.Date executionTime, org.prevayler.foundation.Turn myTurn)
           
 void update(TransactionSubscriber subscriber, long initialTransactionWanted)
          IMPORTANT: This method cannot be called while the log() method is being called in another thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistentLogger

public PersistentLogger(java.lang.String directory,
                        long logSizeThresholdInBytes,
                        long logAgeThresholdInMillis)
                 throws java.io.IOException
Parameters:
directory - Where transactionLog files will be read and written.
logSizeThresholdInBytes - Size of the current transactionLog file beyond which it is closed and a new one started. Zero indicates no size threshold. This is useful transactionLog backup purposes.
logAgeThresholdInMillis - Age of the current transactionLog file beyond which it is closed and a new one started. Zero indicates no age threshold. This is useful transactionLog backup purposes.
Method Detail

log

public void log(Transaction transaction,
                java.util.Date executionTime,
                org.prevayler.foundation.Turn myTurn)
Specified by:
log in interface TransactionLogger

update

public void update(TransactionSubscriber subscriber,
                   long initialTransactionWanted)
            throws java.io.IOException,
                   java.lang.ClassNotFoundException
IMPORTANT: This method cannot be called while the log() method is being called in another thread. If there are no log files in the directory (when a snapshot is taken and all log files are manually deleted, for example), the initialTransaction parameter in the first call to this method will define what the next transaction number will be. We have to find clearer/simpler semantics.

Specified by:
update in interface TransactionLogger
Throws:
java.io.IOException
java.lang.ClassNotFoundException

accept

public boolean accept(java.io.File file)
Implementing FileFilter. 0000000000000000000.transactionLog is the format of the transaction log filename. The long number (19 digits) is the number of the next transaction to be written at the moment the file is created. All transactions written to a file, therefore, have a sequence number greater or equal to the number in its filename.

Specified by:
accept in interface java.io.FileFilter

handleExceptionWhileCreating

protected void handleExceptionWhileCreating(java.io.IOException iox,
                                            java.io.File logFile)

handleExceptionWhileWriting

protected void handleExceptionWhileWriting(java.io.IOException iox,
                                           java.io.File logFile)

close

public void close()
           throws java.io.IOException
Specified by:
close in interface TransactionLogger
Throws:
java.io.IOException


'Prevayler' is a trademark of Klaus Wuestefeld.
Copyleft 2001-2004 Klaus Wuestefeld.