Interface ByteBufferDestination
-
- All Known Implementing Classes:
AbstractSocketManager
,DatagramSocketManager
,FileManager
,MemoryMappedFileManager
,OutputStreamManager
,RandomAccessFileManager
,RollingFileManager
,RollingRandomAccessFileManager
,SslSocketManager
,TcpSocketManager
public interface ByteBufferDestination
ByteBufferDestination is the destination thatEncoder
s write binary data to. It encapsulates aByteBuffer
and adrain()
method the producer can call when theByteBuffer
is full.This interface allows a producer to write arbitrary amounts of data to a destination.
- Since:
- 2.6
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ByteBuffer
drain(ByteBuffer buf)
Consumes the buffer content and returns a buffer with more available space (which may or may not be the same instance).ByteBuffer
getByteBuffer()
Returns the buffer to write to.void
writeBytes(byte[] data, int offset, int length)
Writes the given data to this ByteBufferDestination.void
writeBytes(ByteBuffer data)
Writes the given data to this ByteBufferDestination entirely.
-
-
-
Method Detail
-
getByteBuffer
ByteBuffer getByteBuffer()
Returns the buffer to write to.- Returns:
- the buffer to write to
-
drain
ByteBuffer drain(ByteBuffer buf)
Consumes the buffer content and returns a buffer with more available space (which may or may not be the same instance).Called by the producer when buffer becomes too full to write to.
- Parameters:
buf
- the buffer to drain- Returns:
- a buffer with more available space (which may or may not be the same instance)
-
writeBytes
void writeBytes(ByteBuffer data)
Writes the given data to this ByteBufferDestination entirely. Call of this method should *not* be protected with synchronized on this ByteBufferDestination instance. ByteBufferDestination implementations should synchronize themselves inside this method, if needed.- Since:
- 2.9 (see LOG4J2-1874)
-
writeBytes
void writeBytes(byte[] data, int offset, int length)
Writes the given data to this ByteBufferDestination. Call of this method should *not* be protected with synchronized on this ByteBufferDestination instance. ByteBufferDestination implementations should synchronize themselves inside this method, if needed.This method should behave identically to
writeBytes(ByteBuffer.wrap(data, offset, length)
. It is provided to allow callers not to generate extra garbage.This method is called writeBytes() to avoid clashing with
OutputStreamManager.write(byte[], int, int)
, which might be overridden in user-defined subclasses as protected, hence adding it to interface and requiring the method to be public breaks source compatibility.- Since:
- 2.9 (see LOG4J2-1874)
-
-