org.apache.synapse.transport.passthru

## Class Pipe

- java.lang.Object
- - org.apache.synapse.transport.passthru.Pipe

-     public class Pipe
      extends java.lang.Object

  This is a buffer shared by both producers and consumers.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_TIME_OUT_VALUE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Pipe(ControlledByteBuffer buffer, java.lang.String name, BaseConfiguration baseConfig)`
    `Pipe(org.apache.http.nio.IOControl producerIoControl, ControlledByteBuffer buffer, java.lang.String name, BaseConfiguration baseConfig)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `attachConsumer(org.apache.http.nio.IOControl consumerIoControl)` Set the consumers IOControl
    `int` | `consume(org.apache.http.nio.ContentEncoder encoder)` Consume the data from the buffer.
    `void` | `consumerError()`
    `java.nio.ByteBuffer` | `copyAndConsume(org.apache.http.nio.ContentEncoder encoder)` Consume the data from the buffer.
    `java.nio.ByteBuffer` | `copyAndProduce(org.apache.http.nio.ContentDecoder decoder)` Same as `produce(org.apache.http.nio.ContentDecoder)` and gives a copy of data produced
    `void` | `forceProducerComplete(org.apache.http.nio.ContentDecoder decoder)` Helper method to mark as producer completed.
    `void` | `forceSetSerializationRest()`
    `ControlledByteBuffer` | `getBuffer()`
    `java.io.InputStream` | `getInputStream()` Creates an InputStream object on the underlying ByteBuffer.
    `java.io.OutputStream` | `getOutputStream()` Creates a separate ByteBuffer for the output data and returns an OutputStream on top of it.
    `boolean` | `hasHttpProducer()`
    `boolean` | `isConsumeRequired()` This method returns whether buffer consumption is required or not.
    `boolean` | `isDiscardable()`
    `boolean` | `isProducerCompleted()`
    `boolean` | `isProducerError()` Checks the state of the producerError property
    `boolean` | `isSerializationComplete()`
    `int` | `produce(org.apache.http.nio.ContentDecoder decoder)` Produce data in to the buffer.
    `void` | `producerError()`
    `java.io.OutputStream` | `resetOutputStream()` Creates a separate ByteBuffer for the output data and returns an OutputStream on top of it.
    `void` | `setDiscardable(boolean discardable)`
    `void` | `setRawSerializationComplete(boolean rawSerializationComplete)`
    `void` | `setSerializationComplete(boolean serializationComplete)`
    `java.lang.String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_TIME_OUT_VALUE

          public static final int DEFAULT_TIME_OUT_VALUE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Pipe

          public Pipe(org.apache.http.nio.IOControl producerIoControl,
                      ControlledByteBuffer buffer,
                      java.lang.String name,
                      BaseConfiguration baseConfig)

    - #### Pipe

          public Pipe(ControlledByteBuffer buffer,
                      java.lang.String name,
                      BaseConfiguration baseConfig)

  - ### Method Detail

    - #### isProducerCompleted

          public boolean isProducerCompleted()

    - #### attachConsumer

          public void attachConsumer(org.apache.http.nio.IOControl consumerIoControl)

      Set the consumers IOControl
      Parameters:
        `consumerIoControl` - IOControl of the consumer

    - #### consume

          public int consume(org.apache.http.nio.ContentEncoder encoder)
                      throws java.io.IOException

      Consume the data from the buffer. Before calling this method attachConsumer method must be called with a valid IOControl.
      Parameters:
        `encoder` - encoder used to write the data means there will not be any data written in to this buffer
      Returns:
        number of bytes written (consumed)
      Throws:
        `java.io.IOException` - if an error occurred while consuming data

    - #### copyAndConsume

          public java.nio.ByteBuffer copyAndConsume(org.apache.http.nio.ContentEncoder encoder)
                                             throws java.io.IOException

      Consume the data from the buffer. Same as `consume(org.apache.http.nio.ContentEncoder)` but this gives a copy of data which has been consumed.
      Parameters:
        `encoder` - encoder used to write
      Returns:
        a buffer with data written (consumed)
      Throws:
        `java.io.IOException` - if an error occurred while consuming data

    - #### produce

          public int produce(org.apache.http.nio.ContentDecoder decoder)
                      throws java.io.IOException

      Produce data in to the buffer.
      Parameters:
        `decoder` - decoder to read bytes from the underlying stream
      Returns:
        bytes read (consumed)
      Throws:
        `java.io.IOException` - if an error occurs while reading data

    - #### copyAndProduce

          public java.nio.ByteBuffer copyAndProduce(org.apache.http.nio.ContentDecoder decoder)
                                             throws java.io.IOException

      Same as `produce(org.apache.http.nio.ContentDecoder)` and gives a copy of data produced
      Parameters:
        `decoder` - decoder to read bytes from the underlying stream
      Returns:
        bytes of data read (consumed)
      Throws:
        `java.io.IOException` - if an error occurs while reading data

    - #### forceProducerComplete

          public void forceProducerComplete(org.apache.http.nio.ContentDecoder decoder)

      Helper method to mark as producer completed. The normal behavior only set the boolean param to true only when decoder is completed. However in some cases it is needed to intentionally close chunk stream and mark as producer completed in order to prevent consumer further waiting on end of stream condition.
      Parameters:
        `decoder` - decoder instance to consume input

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### consumerError

          public void consumerError()

    - #### producerError

          public void producerError()

    - #### getInputStream

          public java.io.InputStream getInputStream()

      Creates an InputStream object on the underlying ByteBuffer. The returned InputStream can be used to read bytes from the underlying buffer which is being filled by the producer.
      Returns:
        An InputStream object

    - #### getOutputStream

          public java.io.OutputStream getOutputStream()

      Creates a separate ByteBuffer for the output data and returns an OutputStream on top of it.
      Returns:
        An OutputStream object

    - #### resetOutputStream

          public java.io.OutputStream resetOutputStream()

      Creates a separate ByteBuffer for the output data and returns an OutputStream on top of it.
      Returns:
        An OutputStream object

    - #### setSerializationComplete

          public void setSerializationComplete(boolean serializationComplete)

    - #### setRawSerializationComplete

          public void setRawSerializationComplete(boolean rawSerializationComplete)

    - #### forceSetSerializationRest

          public void forceSetSerializationRest()

    - #### isSerializationComplete

          public boolean isSerializationComplete()

    - #### getBuffer

          public ControlledByteBuffer getBuffer()

    - #### hasHttpProducer

          public boolean hasHttpProducer()

    - #### isDiscardable

          public boolean isDiscardable()

    - #### setDiscardable

          public void setDiscardable(boolean discardable)

    - #### isConsumeRequired

          public boolean isConsumeRequired()
                                    throws java.io.IOException

      This method returns whether buffer consumption is required or not.
      Returns:
        boolean
      Throws:
        `java.io.IOException`

    - #### isProducerError

          public boolean isProducerError()

      Checks the state of the producerError property
      Returns:
        boolean

Copyright © 2005-2022 Apache Software Foundation. All Rights Reserved.