类 PayloadUtils


  • public abstract class PayloadUtils
    extends Object
    Static utility methods to create Payload from DataBuffers and vice versa.
    从以下版本开始:
    5.2
    作者:
    Rossen Stoyanchev
    • 方法详细资料

      • retainDataAndReleasePayload

        public static DataBuffer retainDataAndReleasePayload​(io.rsocket.Payload payload,
                                                             DataBufferFactory bufferFactory)
        Use this method to slice, retain and wrap the data portion of the Payload, and also to release the Payload. This assumes the Payload metadata has been read by now and ensures downstream code need only be aware of DataBuffers.
        参数:
        payload - the payload to process
        bufferFactory - the DataBufferFactory to wrap with
        返回:
        the created DataBuffer instance
      • createPayload

        public static io.rsocket.Payload createPayload​(DataBuffer data,
                                                       DataBuffer metadata)
        Create a Payload from the given metadata and data.

        If at least one is NettyDataBuffer then ByteBufPayload is created with either obtaining the underlying native ByteBuf or using Unpooled.wrappedBuffer(ByteBuffer...) if necessary. Otherwise, if both are DefaultDataBuffer, then DefaultPayload is created.

        参数:
        data - the data part for the payload
        metadata - the metadata part for the payload
        返回:
        the created payload
      • createPayload

        public static io.rsocket.Payload createPayload​(DataBuffer data)
        Create a Payload with data only. The created payload is ByteBufPayload if the input is NettyDataBuffer or otherwise it is DefaultPayload.
        参数:
        data - the data part for the payload
        返回:
        created payload