public class AsynchronousTextWriter extends Object implements TextWriter
The records are buffered in a queue and written asynchronously. If maximum CAPACITY of the queue is
reached, then calls to write() method are blocked. This prevent OOM errors while allowing
good write performances.
TextWriter.Stream| Constructor and Description |
|---|
AsynchronousTextWriter(String name,
boolean autoFlush,
TextWriter writer)
Construct a new AsynchronousTextWriter wrapper.
|
| Modifier and Type | Method and Description |
|---|---|
void |
flush()
Flushes any buffered contents of the output stream.
|
long |
getBytesWritten()
Retrieves the number of bytes written by this writer.
|
TextWriter |
getWrappedWriter()
Retrieves the wrapped writer.
|
void |
shutdown()
Releases any resources held by the writer.
|
void |
shutdown(boolean shutdownWrapped)
Releases any resources held by the writer.
|
void |
write(String record)
Write the log record asynchronously.
|
public AsynchronousTextWriter(String name, boolean autoFlush, TextWriter writer)
name - the name of the thread.autoFlush - indicates if the underlying writer should be flushed after the queue is flushed.writer - a character stream used for output.public void write(String record) throws IOException
write in interface TextWriterrecord - the log record to write.IOException - If a problem occurs.public void flush()
TextWriterflush in interface TextWriterpublic long getBytesWritten()
getBytesWritten in interface TextWriterpublic TextWriter getWrappedWriter()
public void shutdown()
shutdown in interface TextWriterpublic void shutdown(boolean shutdownWrapped)
shutdownWrapped - If the wrapped writer should be closed as well.Copyright © 2025 Open Identity Platform Community. All rights reserved.