org.jwall.web.audit.io
Class AuditLogFileWriter

java.lang.Object
  extended by java.lang.Thread
      extended by org.jwall.web.audit.io.AuditLogFileWriter
All Implemented Interfaces:
java.lang.Runnable, AuditEventListener, AuditEventWriter

public class AuditLogFileWriter
extends java.lang.Thread
implements AuditEventListener, AuditEventWriter

This is a persistence-thread which listens for events and writes them to a file. Writing to a file can also be configured to create a file for each set of events grouped together by the value of the Host-header field.

Author:
Christian Bockermann <chris@jwall.org>

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static java.lang.String VERSION
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
AuditLogFileWriter(java.io.File dir, boolean hostBased, int logLevel)
           
AuditLogFileWriter(java.io.File dir, int logLevel, java.lang.String groupBy)
          This constructor creates a new instance of this class which writes events to several files grouped by a request-property that is given by groupBy.
 
Method Summary
 void add(AuditEvent evt)
           
 void add(java.util.Collection<AuditEvent> evts)
           
 void addAlias(java.lang.String alias, java.lang.String server)
          This method lets you specify an alias for a webserver so that events having this alias in their Host:-header will be written to the same file as the ones with the server-name in the Host-header.
 void addEventListener(AuditEventListener listener)
           
 void addEvents(java.util.Collection<AuditEvent> events)
           
 void close()
           
 void eventArrived(AuditEvent evt)
          this will block if the queue is full !
 int eventsPending()
           
 java.lang.String[] getColumnNames()
           
 java.lang.String getFile()
           
 double[] getStatistics()
          Returns the number of events written since the last call of this method.
 boolean hasEventsPending()
           
 int left()
           
 int length()
           
 void run()
           
 void setSteadyWriter(boolean b)
          A writer not being steady just writes it queue on disk and exits.
 void writeEvent(AuditEvent evt)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION

public static final java.lang.String VERSION
See Also:
Constant Field Values
Constructor Detail

AuditLogFileWriter

public AuditLogFileWriter(java.io.File dir,
                          int logLevel,
                          java.lang.String groupBy)
This constructor creates a new instance of this class which writes events to several files grouped by a request-property that is given by groupBy.

Parameters:
dir - The basic directory where the files are created.
logLevel - A log-level for debugging.
groupBy - The name of the property by which events should by grouped.

AuditLogFileWriter

public AuditLogFileWriter(java.io.File dir,
                          boolean hostBased,
                          int logLevel)
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

writeEvent

public void writeEvent(AuditEvent evt)
                throws java.io.IOException
Specified by:
writeEvent in interface AuditEventWriter
Throws:
java.io.IOException

eventArrived

public void eventArrived(AuditEvent evt)
this will block if the queue is full ! Needs fixing!

Specified by:
eventArrived in interface AuditEventListener

add

public void add(AuditEvent evt)

add

public void add(java.util.Collection<AuditEvent> evts)

addEventListener

public void addEventListener(AuditEventListener listener)

getStatistics

public double[] getStatistics()
Returns the number of events written since the last call of this method.


getColumnNames

public java.lang.String[] getColumnNames()

getFile

public java.lang.String getFile()

addAlias

public void addAlias(java.lang.String alias,
                     java.lang.String server)
This method lets you specify an alias for a webserver so that events having this alias in their Host:-header will be written to the same file as the ones with the server-name in the Host-header.

Parameters:
alias -
server -

hasEventsPending

public boolean hasEventsPending()

eventsPending

public int eventsPending()

addEvents

public void addEvents(java.util.Collection<AuditEvent> events)

length

public int length()

left

public int left()

setSteadyWriter

public void setSteadyWriter(boolean b)
A writer not being steady just writes it queue on disk and exits. A steady writer will wait for new events and then start writing again...

Parameters:
b -

close

public void close()