Module 

Class ConduitReadableMessageChannel

    • Constructor Detail

      • ConduitReadableMessageChannel

        public ConduitReadableMessageChannel​(Configurable configurable,
                                             MessageSourceConduit conduit)
        Construct a new instance.
        Parameters:
        configurable - the configurable to delegate configuration requests to
        conduit - the initial conduit to use for data transport
    • Method Detail

      • getConduit

        public MessageSourceConduit getConduit()
        Get the underlying conduit for this channel.
        Returns:
        the underlying conduit for this channel
      • setConduit

        public void setConduit​(MessageSourceConduit conduit)
        Set the underlying conduit for this channel.
        Parameters:
        conduit - the underlying conduit for this channel
      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in interface java.nio.channels.Channel
      • receive

        public long receive​(java.nio.ByteBuffer[] dsts,
                            int offset,
                            int length)
                     throws java.io.IOException
        Description copied from interface: ReadableMessageChannel
        Receive a message.
        Specified by:
        receive in interface ReadableMessageChannel
        Parameters:
        dsts - the buffers that will hold the message
        offset - the offset into the array of buffers of the first buffer to read into
        length - the number of buffers to fill
        Returns:
        the size of the received message, 0 if no message is available, and -1 if the message channel has reached an end-of-file condition
        Throws:
        java.io.IOException - if an I/O error occurs
      • receive

        public long receive​(java.nio.ByteBuffer[] dsts)
                     throws java.io.IOException
        Description copied from interface: ReadableMessageChannel
        Receive a message.
        Specified by:
        receive in interface ReadableMessageChannel
        Parameters:
        dsts - the buffers that will hold the message
        Returns:
        the size of the received message, 0 if no message is available, and -1 if the message channel has reached an end-of-file condition
        Throws:
        java.io.IOException - if an I/O error occurs
      • receive

        public int receive​(java.nio.ByteBuffer dst)
                    throws java.io.IOException
        Description copied from interface: ReadableMessageChannel
        Receive a message.
        Specified by:
        receive in interface ReadableMessageChannel
        Parameters:
        dst - the buffer that will hold the message
        Returns:
        the size of the received message, 0 if no message is available, and -1 if the message channel has reached an end-of-file condition
        Throws:
        java.io.IOException - if an I/O error occurs
      • shutdownReads

        public void shutdownReads()
                           throws java.io.IOException
        Description copied from interface: SuspendableReadChannel
        Places this readable channel at "end of stream". Further reads will result in EOF. Shutting down all directions of a channel will cause CloseableChannel.close() to be called automatically.
        Specified by:
        shutdownReads in interface SuspendableReadChannel
        Throws:
        java.io.IOException - if an I/O error occurs
      • awaitReadable

        public void awaitReadable()
                           throws java.io.IOException
        Description copied from interface: SuspendableReadChannel
        Block until this channel becomes readable again. This method may return spuriously before the channel becomes readable.
        Specified by:
        awaitReadable in interface SuspendableReadChannel
        Throws:
        java.io.InterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as well
        java.io.IOException - if an I/O error occurs
      • awaitReadable

        public void awaitReadable​(long time,
                                  java.util.concurrent.TimeUnit timeUnit)
                           throws java.io.IOException
        Description copied from interface: SuspendableReadChannel
        Block until this channel becomes readable again, or until the timeout expires. This method may return spuriously before the channel becomes readable or the timeout expires.
        Specified by:
        awaitReadable in interface SuspendableReadChannel
        Parameters:
        time - the time to wait
        timeUnit - the time unit
        Throws:
        java.io.InterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as well
        java.io.IOException - if an I/O error occurs
      • close

        public void close()
                   throws java.io.IOException
        Description copied from interface: CloseableChannel
        Close this channel. When a channel is closed, its close listener is invoked. Invoking this method more than once has no additional effect.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.nio.channels.Channel
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface CloseableChannel
        Specified by:
        close in interface java.nio.channels.InterruptibleChannel
        Throws:
        java.io.IOException - if the close failed
      • supportsOption

        public boolean supportsOption​(Option<?> option)
        Description copied from interface: Configurable
        Determine whether an option is supported on this channel.
        Specified by:
        supportsOption in interface Configurable
        Parameters:
        option - the option
        Returns:
        true if it is supported
      • getOption

        public <T> T getOption​(Option<T> option)
                        throws java.io.IOException
        Description copied from interface: Configurable
        Get the value of a channel option.
        Specified by:
        getOption in interface Configurable
        Type Parameters:
        T - the type of the option value
        Parameters:
        option - the option to get
        Returns:
        the value of the option, or null if it is not set
        Throws:
        java.io.IOException - if an I/O error occurred when reading the option
      • setOption

        public <T> T setOption​(Option<T> option,
                               T value)
                        throws java.lang.IllegalArgumentException,
                               java.io.IOException
        Description copied from interface: Configurable
        Set an option for this channel. Unsupported options are ignored.
        Specified by:
        setOption in interface Configurable
        Type Parameters:
        T - the type of the option value
        Parameters:
        option - the option to set
        value - the value of the option to set
        Returns:
        the previous option value, if any
        Throws:
        java.lang.IllegalArgumentException - if the value is not acceptable for this option
        java.io.IOException - if an I/O error occurred when modifying the option
      • clone

        public ConduitReadableMessageChannel clone()
        Duplicate this channel. Changing the delegate conduit in one channel will not affect the other.
        Overrides:
        clone in class java.lang.Object
        Returns:
        the cloned channel