Top Description Fields Constructors Methods
ch.qos.logback.core.net

public Class AutoFlushingObjectWriter

extends Object
implements ObjectWriter
Class Inheritance
All Implemented Interfaces
ch.qos.logback.core.net.ObjectWriter
Imports
java.io.IOException, .ObjectOutputStream

Automatically flushes the underlying java.io.ObjectOutputStream immediately after calling it's java.io.ObjectOutputStream#writeObject(Object) method.
Author
Sebastian Gröbler

Field Summary

Modifier and TypeField and Description
private final ObjectOutputStream
private final int
private int

Constructor Summary

AccessConstructor and Description
public
AutoFlushingObjectWriter(ObjectOutputStream
the stream to write to
objectOutputStream
,
int
the frequency with which the given stream will be automatically reset to prevent a memory leak
resetFrequency
)

Creates a new instance for the given java.io.ObjectOutputStream.

Method Summary

Modifier and TypeMethod and Description
private void
preventMemoryLeak()

Failing to reset the object output stream every now and then creates a serious memory leak which is why the underlying stream will be reset according to the resetFrequency.

public void
write(Object
the Object to write
object
)

Implements ch.qos.logback.core.net.ObjectWriter.write.

Writes an object to an output.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

objectOutputStreamback to summary
private final ObjectOutputStream objectOutputStream
resetFrequencyback to summary
private final int resetFrequency
writeCounterback to summary
private int writeCounter

Constructor Detail

AutoFlushingObjectWriterback to summary
public AutoFlushingObjectWriter(ObjectOutputStream objectOutputStream, int resetFrequency)

Creates a new instance for the given java.io.ObjectOutputStream.

Parameters
objectOutputStream:ObjectOutputStream

the stream to write to

resetFrequency:int

the frequency with which the given stream will be automatically reset to prevent a memory leak

Method Detail

preventMemoryLeakback to summary
private void preventMemoryLeak() throws IOException

Failing to reset the object output stream every now and then creates a serious memory leak which is why the underlying stream will be reset according to the resetFrequency.

writeback to summary
public void write(Object object) throws IOException

Implements ch.qos.logback.core.net.ObjectWriter.write.

Doc from ch.qos.logback.core.net.ObjectWriter.write.

Writes an object to an output.

Parameters
object:Object

the Object to write

Annotations
@Override
Exceptions
IOException:
in case input/output fails, details are defined by the implementation