Class ByteBufDataChunk

java.lang.Object
io.helidon.webserver.ByteBufDataChunk
All Implemented Interfaces:
DataChunk, Iterable<ByteBuffer>

public class ByteBufDataChunk extends Object implements DataChunk
A special DataChunk implementation based on Netty's buffers. This is used by our Jersey SPI implementation to take advantage of Netty's buffer pooling.
  • Method Details

    • create

      public static ByteBufDataChunk create(boolean flush, boolean readOnly, io.netty.buffer.ByteBuf... byteBufs)
      Creates an instance given an array of ByteBuf's.
      Parameters:
      flush - a signal that this chunk should be written and flushed from any cache if possible
      readOnly - marks this buffer as read only
      byteBufs - the data for this chunk. Should not be reused until releaseCallback is used
      Returns:
      new chunk
    • create

      public static ByteBufDataChunk create(boolean flush, boolean readOnly, Runnable releaseCallback, io.netty.buffer.ByteBuf... byteBufs)
      Creates an instance given an array of ByteBuf's.
      Parameters:
      flush - a signal that this chunk should be written and flushed from any cache if possible
      readOnly - marks this buffer as read only
      releaseCallback - a callback which is called when this chunk is completely processed
      byteBufs - the data for this chunk. Should not be reused until releaseCallback is used
      Returns:
      new chunk
    • isBackedBy

      public <T> boolean isBackedBy(Class<T> clazz)
      Specified by:
      isBackedBy in interface DataChunk
    • data

      public <T> T[] data(Class<T> clazz)
      Specified by:
      data in interface DataChunk
    • isReleased

      public boolean isReleased()
      Specified by:
      isReleased in interface DataChunk
    • flush

      public boolean flush()
      Specified by:
      flush in interface DataChunk
    • isReadOnly

      public boolean isReadOnly()
      Specified by:
      isReadOnly in interface DataChunk
    • release

      public void release()
      Specified by:
      release in interface DataChunk
    • writeFuture

      public void writeFuture(CompletableFuture<DataChunk> writeFuture)
      Specified by:
      writeFuture in interface DataChunk
    • writeFuture

      public Optional<CompletableFuture<DataChunk>> writeFuture()
      Specified by:
      writeFuture in interface DataChunk
    • remaining

      public int remaining()
      Specified by:
      remaining in interface DataChunk
    • data

      public ByteBuffer[] data()
      This method is needed for testing some of our examples. It bypasses the optimization for which this class was created.
      Specified by:
      data in interface DataChunk
      Returns:
      array of ByteBuffer
    • duplicate

      public DataChunk duplicate()
      Specified by:
      duplicate in interface DataChunk
    • bytes

      public byte[] bytes()
      Specified by:
      bytes in interface DataChunk
    • iterator

      public Iterator<ByteBuffer> iterator()
      Specified by:
      iterator in interface DataChunk
      Specified by:
      iterator in interface Iterable<ByteBuffer>