Module 

Class AssembledMessageChannel

    • Constructor Detail

      • AssembledMessageChannel

        public AssembledMessageChannel​(CloseableChannel closeable,
                                       ReadableMessageChannel readable,
                                       WritableMessageChannel writable)
        Construct a new instance.
        Parameters:
        closeable - the single central closeable channel
        readable - the read channel
        writable - the write channel
      • AssembledMessageChannel

        public AssembledMessageChannel​(ReadableMessageChannel readable,
                                       WritableMessageChannel writable)
        Construct a new instance.
        Parameters:
        readable - the read channel
        writable - the write channel
    • Method Detail

      • 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
      • receive

        public int receive​(java.nio.ByteBuffer buffer)
                    throws java.io.IOException
        Description copied from interface: ReadableMessageChannel
        Receive a message.
        Specified by:
        receive in interface ReadableMessageChannel
        Parameters:
        buffer - 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
      • receive

        public long receive​(java.nio.ByteBuffer[] buffers)
                     throws java.io.IOException
        Description copied from interface: ReadableMessageChannel
        Receive a message.
        Specified by:
        receive in interface ReadableMessageChannel
        Parameters:
        buffers - 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 long receive​(java.nio.ByteBuffer[] buffers,
                            int offs,
                            int len)
                     throws java.io.IOException
        Description copied from interface: ReadableMessageChannel
        Receive a message.
        Specified by:
        receive in interface ReadableMessageChannel
        Parameters:
        buffers - the buffers that will hold the message
        offs - the offset into the array of buffers of the first buffer to read into
        len - 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
      • shutdownWrites

        public void shutdownWrites()
                            throws java.io.IOException
        Description copied from interface: SuspendableWriteChannel
        Indicate that writing is complete for this channel. Further attempts to write data to this channel after this method is invoked will result in an exception. If this method was already called, calling this method again will have no additional effect. After this method is called, any remaining data still must be flushed out via the SuspendableWriteChannel.flush() method; once this is done, if the read side of the channel was shut down, the channel will automatically close.
        Specified by:
        shutdownWrites in interface SuspendableWriteChannel
        Throws:
        java.io.IOException - if an I/O error occurs
      • awaitWritable

        public void awaitWritable()
                           throws java.io.IOException
        Description copied from interface: SuspendableWriteChannel
        Block until this channel becomes writable again. This method may return spuriously before the channel becomes writable.
        Specified by:
        awaitWritable in interface SuspendableWriteChannel
        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
      • awaitWritable

        public void awaitWritable​(long time,
                                  java.util.concurrent.TimeUnit timeUnit)
                           throws java.io.IOException
        Description copied from interface: SuspendableWriteChannel
        Block until this channel becomes writable again, or until the timeout expires. This method may return spuriously before the channel becomes writable or the timeout expires.
        Specified by:
        awaitWritable in interface SuspendableWriteChannel
        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
      • send

        public boolean send​(java.nio.ByteBuffer buffer)
                     throws java.io.IOException
        Description copied from interface: WritableMessageChannel
        Send a complete message.
        Specified by:
        send in interface WritableMessageChannel
        Parameters:
        buffer - the message to send
        Returns:
        the result of the send operation; true if the message was sent, or false if it would block
        Throws:
        java.io.IOException - if an I/O error occurs
      • send

        public boolean send​(java.nio.ByteBuffer[] buffers)
                     throws java.io.IOException
        Description copied from interface: WritableMessageChannel
        Send a complete message.
        Specified by:
        send in interface WritableMessageChannel
        Parameters:
        buffers - the buffers holding the message to send
        Returns:
        the result of the send operation; true if the message was sent, or false if it would block
        Throws:
        java.io.IOException - if an I/O error occurs
      • send

        public boolean send​(java.nio.ByteBuffer[] buffers,
                            int offs,
                            int len)
                     throws java.io.IOException
        Description copied from interface: WritableMessageChannel
        Send a complete message.
        Specified by:
        send in interface WritableMessageChannel
        Parameters:
        buffers - the buffers holding the message to send
        offs - the offset into the buffer array of the first buffer
        len - the number of buffers that contain data to send
        Returns:
        the result of the send operation; true if the message was sent, or false if it would block
        Throws:
        java.io.IOException - if an I/O error occurs
      • sendFinal

        public boolean sendFinal​(java.nio.ByteBuffer buffer)
                          throws java.io.IOException
        Description copied from interface: WritableMessageChannel
        Send a complete message. If the message was successfully sent the channel with have its writes shutdown.
        Specified by:
        sendFinal in interface WritableMessageChannel
        Parameters:
        buffer - the message to send
        Returns:
        the result of the send operation; true if the message was sent, or false if it would block
        Throws:
        java.io.IOException - if an I/O error occurs
      • sendFinal

        public boolean sendFinal​(java.nio.ByteBuffer[] buffers)
                          throws java.io.IOException
        Description copied from interface: WritableMessageChannel
        Send a complete message. If the message was successfully sent the channel with have its writes shutdown.
        Specified by:
        sendFinal in interface WritableMessageChannel
        Parameters:
        buffers - the buffers holding the message to send
        Returns:
        the result of the send operation; true if the message was sent, or false if it would block
        Throws:
        java.io.IOException - if an I/O error occurs
      • sendFinal

        public boolean sendFinal​(java.nio.ByteBuffer[] buffers,
                                 int offs,
                                 int len)
                          throws java.io.IOException
        Description copied from interface: WritableMessageChannel
        Send a complete message. If the message was successfully sent the channel with have its writes shutdown.
        Specified by:
        sendFinal in interface WritableMessageChannel
        Parameters:
        buffers - the buffers holding the message to send
        offs - the offset into the buffer array of the first buffer
        len - the number of buffers that contain data to send
        Returns:
        the result of the send operation; true if the message was sent, or false if it would block
        Throws:
        java.io.IOException - if an I/O error occurs
      • flush

        public boolean flush()
                      throws java.io.IOException
        Description copied from interface: SuspendableWriteChannel
        Flush any waiting partial send or write. If there is no data to flush, or if the flush completed successfully, this method will return true. If there is data to flush which cannot be immediately written, this method will return false. If this method returns true after SuspendableWriteChannel.shutdownWrites() was called on this channel, the write listener will no longer be invoked on this channel. If this is case and additionally this is a write-only channel or the read side was previously shut down, then the channel will automatically be closed.
        Specified by:
        flush in interface SuspendableWriteChannel
        Returns:
        true if the message was flushed, or false if the result would block
        Throws:
        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
        Specified by:
        close in interface SuspendableWriteChannel
        Throws:
        java.io.IOException - if the close failed
      • isOpen

        public boolean isOpen()
        Description copied from interface: SuspendableWriteChannel
        Determine whether this channel is open. This method will return false if all directions are shut down, even if there is unflushed write data pending.
        Specified by:
        isOpen in interface java.nio.channels.Channel
        Specified by:
        isOpen in interface SuspendableWriteChannel
        Returns:
        true if the channel is open, false otherwise
      • 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