Holger's
Java API

com.antelmann.util.logging
Class AsynchLogWriter

java.lang.Object
  extended by com.antelmann.util.logging.AsynchLogWriter
All Implemented Interfaces:
Filter<LogEntry>, LogWriter, Wrapped<LogWriter>

public class AsynchLogWriter
extends Object
implements LogWriter, Wrapped<LogWriter>

allows to operate any LogWriter asynchronously.

Author:
Holger Antelmann

Field Summary
 
Fields inherited from interface com.antelmann.util.Filter
EXCLUDE_ALL_FILTER, INCLUDE_ALL_FILTER
 
Constructor Summary
AsynchLogWriter(LogWriter writer, Executor worker)
           
 
Method Summary
 boolean accept(LogEntry entry)
          delegates to the writer synchronously
 LogException[] clearExceptions()
          returns all exceptions that may have been accumulated until this call and clears the embedded list
 Executor getExecutor()
           
 LogWriter getWriter()
           
 LogWriter unwrap()
          returns the embedded instance that this wrapper encloses
 void write(LogEntry entry)
          creates a task that runs asynchronously and delegates to the embedded writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsynchLogWriter

public AsynchLogWriter(LogWriter writer,
                       Executor worker)
Method Detail

accept

public boolean accept(LogEntry entry)
delegates to the writer synchronously

Specified by:
accept in interface Filter<LogEntry>

write

public void write(LogEntry entry)
           throws LogException
creates a task that runs asynchronously and delegates to the embedded writer. If a LogException is thrown while the Executor runs, it will be thrown back to the caller on the next call after the exception was thrown.

Specified by:
write in interface LogWriter
Throws:
LogException - if an error occurred while writing the log

getExecutor

public Executor getExecutor()

getWriter

public LogWriter getWriter()

unwrap

public LogWriter unwrap()
Description copied from interface: Wrapped
returns the embedded instance that this wrapper encloses

Specified by:
unwrap in interface Wrapped<LogWriter>

clearExceptions

public LogException[] clearExceptions()
returns all exceptions that may have been accumulated until this call and clears the embedded list



(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads