Top Description Fields Constructors Methods
org.xnio.channels

public Class AssembledMessageChannel

extends Object
implements MessageChannel
Class Inheritance
All Implemented Interfaces
org.xnio.channels.MessageChannel, org.xnio.channels.SuspendableChannel, org.xnio.channels.SuspendableWriteChannel, org.xnio.channels.CloseableChannel, org.xnio.channels.Configurable, java.nio.channels.InterruptibleChannel, java.nio.channels.Channel, java.io.Closeable, java.lang.AutoCloseable, org.xnio.channels.SuspendableReadChannel, org.xnio.channels.WritableMessageChannel, org.xnio.channels.ReadableMessageChannel
Known Direct Subclasses
org.xnio.channels.AssembledConnectedMessageChannel
Static Imports
org.xnio._private.Messages.msg

A bidirectional message channel assembled from a readable and writable message channel.
Author
David M. Lloyd

Field Summary

Modifier and TypeField and Description
private final CloseableChannel
private final ChannelListener.Setter<AssembledMessageChannel>
private final ReadableMessageChannel
private final ChannelListener.Setter<AssembledMessageChannel>
private final WritableMessageChannel
private final ChannelListener.Setter<AssembledMessageChannel>

Constructor Summary

AccessConstructor and Description
public
AssembledMessageChannel(final CloseableChannel
the single central closeable channel
closeable
,
final ReadableMessageChannel
the read channel
readable
,
final WritableMessageChannel
the write channel
writable
)

Construct a new instance.

public
AssembledMessageChannel(final ReadableMessageChannel
the read channel
readable
,
final WritableMessageChannel
the write channel
writable
)

Construct a new instance.

Method Summary

Modifier and TypeMethod and Description
public void
awaitReadable()

Implements org.xnio.channels.SuspendableReadChannel.awaitReadable.

Block until this channel becomes readable again.

public void
awaitReadable(final long
the time to wait
time
,
final TimeUnit
the time unit
timeUnit
)

Implements org.xnio.channels.SuspendableReadChannel.awaitReadable.

Block until this channel becomes readable again, or until the timeout expires.

public void
awaitWritable()

Implements org.xnio.channels.SuspendableWriteChannel.awaitWritable.

Block until this channel becomes writable again.

public void
awaitWritable(final long
the time to wait
time
,
final TimeUnit
the time unit
timeUnit
)

Implements org.xnio.channels.SuspendableWriteChannel.awaitWritable.

Block until this channel becomes writable again, or until the timeout expires.

public void
public boolean
flush()

Implements org.xnio.channels.SuspendableWriteChannel.flush.

Flush any waiting partial send or write.

public ChannelListener.Setter<? extends AssembledMessageChannel>
getCloseSetter()

Implements org.xnio.channels.MessageChannel.getCloseSetter.

Get the setter which can be used to change the close listener for this channel.

public XnioIoThread
getIoThread()

Implements org.xnio.channels.CloseableChannel.getIoThread.

Get the I/O thread associated with this channel.

public <T> T
getOption(final Option<T>
the option to get
option
)

Implements org.xnio.channels.Configurable.getOption.

Get the value of a channel option.

public ChannelListener.Setter<? extends AssembledMessageChannel>
getReadSetter()

Implements org.xnio.channels.MessageChannel.getReadSetter.

Get the setter which can be used to change the read listener for this channel.

public XnioExecutor
getReadThread()

Implements org.xnio.channels.SuspendableReadChannel.getReadThread.

Deprecated

Get the read thread for this channel.

public XnioWorker
getWorker()

Implements org.xnio.channels.CloseableChannel.getWorker.

Get the worker for this channel.

public ChannelListener.Setter<? extends AssembledMessageChannel>
getWriteSetter()

Implements org.xnio.channels.MessageChannel.getWriteSetter.

Get the setter which can be used to change the write listener for this channel.

public XnioExecutor
getWriteThread()

Implements org.xnio.channels.SuspendableWriteChannel.getWriteThread.

Deprecated

Get the write thread for this channel.

public boolean
isOpen()

Implements java.nio.channels.Channel.isOpen, org.xnio.channels.SuspendableWriteChannel.isOpen.

Tells whether or not this channel is open.

public boolean
isReadResumed()

Implements org.xnio.channels.SuspendableReadChannel.isReadResumed.

Determine whether reads are resumed.

public boolean
isWriteResumed()

Implements org.xnio.channels.SuspendableWriteChannel.isWriteResumed.

Determine whether writes are resumed.

public int
receive(final ByteBuffer
the buffer that will hold the message
buffer
)

Implements org.xnio.channels.ReadableMessageChannel.receive.

Receive a message.

public long
receive(final ByteBuffer[]
the buffers that will hold the message
buffers
)

Implements org.xnio.channels.ReadableMessageChannel.receive.

Receive a message.

public long
receive(final ByteBuffer[]
the buffers that will hold the message
buffers
,
final int
the offset into the array of buffers of the first buffer to read into
offs
,
final int
the number of buffers to fill
len
)

Implements org.xnio.channels.ReadableMessageChannel.receive.

Receive a message.

public void
resumeReads()

Implements org.xnio.channels.SuspendableReadChannel.resumeReads.

Resume reads on this channel.

public void
resumeWrites()

Implements org.xnio.channels.SuspendableWriteChannel.resumeWrites.

Resume writes on this channel.

public boolean
send(final ByteBuffer
the message to send
buffer
)

Implements org.xnio.channels.WritableMessageChannel.send.

Send a complete message.

public boolean
send(final ByteBuffer[]
the buffers holding the message to send
buffers
)

Implements org.xnio.channels.WritableMessageChannel.send.

Send a complete message.

public boolean
send(final ByteBuffer[]
the buffers holding the message to send
buffers
,
final int
the offset into the buffer array of the first buffer
offs
,
final int
the number of buffers that contain data to send
len
)

Implements org.xnio.channels.WritableMessageChannel.send.

Send a complete message.

public boolean
sendFinal(ByteBuffer
the message to send
buffer
)

Implements org.xnio.channels.WritableMessageChannel.sendFinal.

Send a complete message.

public boolean
sendFinal(ByteBuffer[]
the buffers holding the message to send
buffers
)

Implements org.xnio.channels.WritableMessageChannel.sendFinal.

Send a complete message.

public boolean
sendFinal(ByteBuffer[]
the buffers holding the message to send
buffers
,
int
the offset into the buffer array of the first buffer
offs
,
int
the number of buffers that contain data to send
len
)

Implements org.xnio.channels.WritableMessageChannel.sendFinal.

Send a complete message.

public <T> T
setOption(final Option<T>
the option to set
option
,
final T
the value of the option to set
value
)

Implements org.xnio.channels.Configurable.setOption.

Set an option for this channel.

public void
shutdownReads()

Implements org.xnio.channels.SuspendableReadChannel.shutdownReads.

Places this readable channel at "end of stream".

public void
shutdownWrites()

Implements org.xnio.channels.SuspendableWriteChannel.shutdownWrites.

Indicate that writing is complete for this channel.

public boolean
supportsOption(final Option<?>
the option
option
)

Implements org.xnio.channels.Configurable.supportsOption.

Determine whether an option is supported on this channel.

public void
suspendReads()

Implements org.xnio.channels.SuspendableReadChannel.suspendReads.

Suspend further read notifications on this channel.

public void
suspendWrites()

Implements org.xnio.channels.SuspendableWriteChannel.suspendWrites.

Suspend further write notifications on this channel.

public void
wakeupReads()

Implements org.xnio.channels.SuspendableReadChannel.wakeupReads.

Resume reads on this channel, and force the read listener to be triggered even if the channel isn't actually readable.

public void
wakeupWrites()

Implements org.xnio.channels.SuspendableWriteChannel.wakeupWrites.

Resume writes on this channel, and force the write listener to be triggered even if the channel isn't actually writable.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

closeableback to summary
private final CloseableChannel closeable
closeSetterback to summary
private final ChannelListener.Setter<AssembledMessageChannel> closeSetter
readableback to summary
private final ReadableMessageChannel readable
readSetterback to summary
private final ChannelListener.Setter<AssembledMessageChannel> readSetter
writableback to summary
private final WritableMessageChannel writable
writeSetterback to summary
private final ChannelListener.Setter<AssembledMessageChannel> writeSetter

Constructor Detail

AssembledMessageChannelback to summary
public AssembledMessageChannel(final CloseableChannel closeable, final ReadableMessageChannel readable, final WritableMessageChannel writable)

Construct a new instance.

Parameters
closeable:CloseableChannel

the single central closeable channel

readable:ReadableMessageChannel

the read channel

writable:WritableMessageChannel

the write channel

AssembledMessageChannelback to summary
public AssembledMessageChannel(final ReadableMessageChannel readable, final WritableMessageChannel writable)

Construct a new instance.

Parameters
readable:ReadableMessageChannel

the read channel

writable:WritableMessageChannel

the write channel

Method Detail

awaitReadableback to summary
public void awaitReadable() throws IOException

Implements org.xnio.channels.SuspendableReadChannel.awaitReadable.

Doc from org.xnio.channels.SuspendableReadChannel.awaitReadable.

Block until this channel becomes readable again. This method may return spuriously before the channel becomes readable.

Exceptions
IOException:
if an I/O error occurs
awaitReadableback to summary
public void awaitReadable(final long time, final TimeUnit timeUnit) throws IOException

Implements org.xnio.channels.SuspendableReadChannel.awaitReadable.

Doc from org.xnio.channels.SuspendableReadChannel.awaitReadable.

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.

Parameters
time:long

the time to wait

timeUnit:TimeUnit

the time unit

Exceptions
IOException:
if an I/O error occurs
awaitWritableback to summary
public void awaitWritable() throws IOException

Implements org.xnio.channels.SuspendableWriteChannel.awaitWritable.

Doc from org.xnio.channels.SuspendableWriteChannel.awaitWritable.

Block until this channel becomes writable again. This method may return spuriously before the channel becomes writable.

Exceptions
IOException:
if an I/O error occurs
awaitWritableback to summary
public void awaitWritable(final long time, final TimeUnit timeUnit) throws IOException

Implements org.xnio.channels.SuspendableWriteChannel.awaitWritable.

Doc from org.xnio.channels.SuspendableWriteChannel.awaitWritable.

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.

Parameters
time:long

the time to wait

timeUnit:TimeUnit

the time unit

Exceptions
IOException:
if an I/O error occurs
closeback to summary
public void close() throws IOException

Implements org.xnio.channels.CloseableChannel.close, org.xnio.channels.SuspendableWriteChannel.close.

Doc from org.xnio.channels.CloseableChannel.close.

Close this channel. When a channel is closed, its close listener is invoked. Invoking this method more than once has no additional effect.

Exceptions
IOException:
if the close failed
flushback to summary
public boolean flush() throws IOException

Implements org.xnio.channels.SuspendableWriteChannel.flush.

Doc from org.xnio.channels.SuspendableWriteChannel.flush.

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 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.

Returns:boolean

true if the message was flushed, or false if the result would block

Exceptions
IOException:
if an I/O error occurs
getCloseSetterback to summary
public ChannelListener.Setter<? extends AssembledMessageChannel> getCloseSetter()

Implements org.xnio.channels.MessageChannel.getCloseSetter.

Doc from org.xnio.channels.MessageChannel.getCloseSetter.

Get the setter which can be used to change the close listener for this channel. If the channel is already closed, then the listener will not be called.

Returns:ChannelListener.Setter<? extends AssembledMessageChannel>

Doc from org.xnio.channels.CloseableChannel.getCloseSetter.

the setter

getIoThreadback to summary
public XnioIoThread getIoThread()

Implements org.xnio.channels.CloseableChannel.getIoThread.

Doc from org.xnio.channels.CloseableChannel.getIoThread.

Get the I/O thread associated with this channel.

Returns:XnioIoThread

the I/O thread associated with this channel

getOptionback to summary
public <T> T getOption(final Option<T> option) throws IOException

Implements org.xnio.channels.Configurable.getOption.

Doc from org.xnio.channels.Configurable.getOption.

Get the value of a channel option.

Parameters
<T>
the type of the option value
option:Option<T>

the option to get

Returns:T

the value of the option, or null if it is not set

Exceptions
IOException:
if an I/O error occurred when reading the option
getReadSetterback to summary
public ChannelListener.Setter<? extends AssembledMessageChannel> getReadSetter()

Implements org.xnio.channels.MessageChannel.getReadSetter.

Doc from org.xnio.channels.MessageChannel.getReadSetter.

Get the setter which can be used to change the read listener for this channel.

Returns:ChannelListener.Setter<? extends AssembledMessageChannel>

Doc from org.xnio.channels.SuspendableReadChannel.getReadSetter.

the setter

getReadThreadback to summary
public XnioExecutor getReadThread()

Implements org.xnio.channels.SuspendableReadChannel.getReadThread.

Doc from org.xnio.channels.SuspendableReadChannel.getReadThread.

Deprecated

Get the read thread for this channel.

Returns:XnioExecutor

the thread, or null if none is configured or available

Annotations
@Deprecated
getWorkerback to summary
public XnioWorker getWorker()

Implements org.xnio.channels.CloseableChannel.getWorker.

Doc from org.xnio.channels.CloseableChannel.getWorker.

Get the worker for this channel.

Returns:XnioWorker

the worker

getWriteSetterback to summary
public ChannelListener.Setter<? extends AssembledMessageChannel> getWriteSetter()

Implements org.xnio.channels.MessageChannel.getWriteSetter.

Doc from org.xnio.channels.MessageChannel.getWriteSetter.

Get the setter which can be used to change the write listener for this channel.

Returns:ChannelListener.Setter<? extends AssembledMessageChannel>

Doc from org.xnio.channels.SuspendableWriteChannel.getWriteSetter.

the setter

getWriteThreadback to summary
public XnioExecutor getWriteThread()

Implements org.xnio.channels.SuspendableWriteChannel.getWriteThread.

Doc from org.xnio.channels.SuspendableWriteChannel.getWriteThread.

Deprecated

Get the write thread for this channel.

Returns:XnioExecutor

the thread, or null if none is configured or available

Annotations
@Deprecated
isOpenback to summary
public boolean isOpen()

Implements java.nio.channels.Channel.isOpen, org.xnio.channels.SuspendableWriteChannel.isOpen.

Doc from java.nio.channels.Channel.isOpen.

Tells whether or not this channel is open.

Returns:boolean

true if, and only if, this channel is open

isReadResumedback to summary
public boolean isReadResumed()

Implements org.xnio.channels.SuspendableReadChannel.isReadResumed.

Doc from org.xnio.channels.SuspendableReadChannel.isReadResumed.

Determine whether reads are resumed.

Returns:boolean

true if reads are resumed, false if reads are suspended

isWriteResumedback to summary
public boolean isWriteResumed()

Implements org.xnio.channels.SuspendableWriteChannel.isWriteResumed.

Doc from org.xnio.channels.SuspendableWriteChannel.isWriteResumed.

Determine whether writes are resumed.

Returns:boolean

true if writes are resumed, false if writes are suspended

receiveback to summary
public int receive(final ByteBuffer buffer) throws IOException

Implements org.xnio.channels.ReadableMessageChannel.receive.

Doc from org.xnio.channels.ReadableMessageChannel.receive.

Receive a message.

Parameters
buffer:ByteBuffer

the buffer that will hold the message

Returns:int

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

Exceptions
IOException:
if an I/O error occurs
receiveback to summary
public long receive(final ByteBuffer[] buffers) throws IOException

Implements org.xnio.channels.ReadableMessageChannel.receive.

Doc from org.xnio.channels.ReadableMessageChannel.receive.

Receive a message.

Parameters
buffers:ByteBuffer[]

the buffers that will hold the message

Returns:long

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

Exceptions
IOException:
if an I/O error occurs
receiveback to summary
public long receive(final ByteBuffer[] buffers, final int offs, final int len) throws IOException

Implements org.xnio.channels.ReadableMessageChannel.receive.

Doc from org.xnio.channels.ReadableMessageChannel.receive.

Receive a message.

Parameters
buffers:ByteBuffer[]

the buffers that will hold the message

offs:int

the offset into the array of buffers of the first buffer to read into

len:int

the number of buffers to fill

Returns:long

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

Exceptions
IOException:
if an I/O error occurs
resumeReadsback to summary
public void resumeReads()

Implements org.xnio.channels.SuspendableReadChannel.resumeReads.

Doc from org.xnio.channels.SuspendableReadChannel.resumeReads.

Resume reads on this channel. The read listener will be called as soon as there is data available to be read.

resumeWritesback to summary
public void resumeWrites()

Implements org.xnio.channels.SuspendableWriteChannel.resumeWrites.

Doc from org.xnio.channels.SuspendableWriteChannel.resumeWrites.

Resume writes on this channel. The write listener will be called as soon as the channel becomes writable.

sendback to summary
public boolean send(final ByteBuffer buffer) throws IOException

Implements org.xnio.channels.WritableMessageChannel.send.

Doc from org.xnio.channels.WritableMessageChannel.send.

Send a complete message.

Parameters
buffer:ByteBuffer

the message to send

Returns:boolean

the result of the send operation; true if the message was sent, or false if it would block

Exceptions
IOException:
if an I/O error occurs
sendback to summary
public boolean send(final ByteBuffer[] buffers) throws IOException

Implements org.xnio.channels.WritableMessageChannel.send.

Doc from org.xnio.channels.WritableMessageChannel.send.

Send a complete message.

Parameters
buffers:ByteBuffer[]

the buffers holding the message to send

Returns:boolean

the result of the send operation; true if the message was sent, or false if it would block

Exceptions
IOException:
if an I/O error occurs
sendback to summary
public boolean send(final ByteBuffer[] buffers, final int offs, final int len) throws IOException

Implements org.xnio.channels.WritableMessageChannel.send.

Doc from org.xnio.channels.WritableMessageChannel.send.

Send a complete message.

Parameters
buffers:ByteBuffer[]

the buffers holding the message to send

offs:int

the offset into the buffer array of the first buffer

len:int

the number of buffers that contain data to send

Returns:boolean

the result of the send operation; true if the message was sent, or false if it would block

Exceptions
IOException:
if an I/O error occurs
sendFinalback to summary
public boolean sendFinal(ByteBuffer buffer) throws IOException

Implements org.xnio.channels.WritableMessageChannel.sendFinal.

Doc from org.xnio.channels.WritableMessageChannel.sendFinal.

Send a complete message. If the message was successfully sent the channel with have its writes shutdown.

Parameters
buffer:ByteBuffer

the message to send

Returns:boolean

the result of the send operation; true if the message was sent, or false if it would block

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
sendFinalback to summary
public boolean sendFinal(ByteBuffer[] buffers) throws IOException

Implements org.xnio.channels.WritableMessageChannel.sendFinal.

Doc from org.xnio.channels.WritableMessageChannel.sendFinal.

Send a complete message. If the message was successfully sent the channel with have its writes shutdown.

Parameters
buffers:ByteBuffer[]

the buffers holding the message to send

Returns:boolean

the result of the send operation; true if the message was sent, or false if it would block

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
sendFinalback to summary
public boolean sendFinal(ByteBuffer[] buffers, int offs, int len) throws IOException

Implements org.xnio.channels.WritableMessageChannel.sendFinal.

Doc from org.xnio.channels.WritableMessageChannel.sendFinal.

Send a complete message. If the message was successfully sent the channel with have its writes shutdown.

Parameters
buffers:ByteBuffer[]

the buffers holding the message to send

offs:int

the offset into the buffer array of the first buffer

len:int

the number of buffers that contain data to send

Returns:boolean

the result of the send operation; true if the message was sent, or false if it would block

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
setOptionback to summary
public <T> T setOption(final Option<T> option, final T value) throws IllegalArgumentException, IOException

Implements org.xnio.channels.Configurable.setOption.

Doc from org.xnio.channels.Configurable.setOption.

Set an option for this channel. Unsupported options are ignored.

Parameters
<T>
the type of the option value
option:Option<T>

the option to set

value:T

the value of the option to set

Returns:T

the previous option value, if any

Exceptions
IllegalArgumentException:
if the value is not acceptable for this option
IOException:
if an I/O error occurred when modifying the option
shutdownReadsback to summary
public void shutdownReads() throws IOException

Implements org.xnio.channels.SuspendableReadChannel.shutdownReads.

Doc from org.xnio.channels.SuspendableReadChannel.shutdownReads.

Places this readable channel at "end of stream". Further reads will result in EOF. Shutting down all directions of a channel will cause close() to be called automatically.

Exceptions
IOException:
if an I/O error occurs
shutdownWritesback to summary
public void shutdownWrites() throws IOException

Implements org.xnio.channels.SuspendableWriteChannel.shutdownWrites.

Doc from org.xnio.channels.SuspendableWriteChannel.shutdownWrites.

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 flush() method; once this is done, if the read side of the channel was shut down, the channel will automatically close.

Exceptions
IOException:
if an I/O error occurs
supportsOptionback to summary
public boolean supportsOption(final Option<?> option)

Implements org.xnio.channels.Configurable.supportsOption.

Doc from org.xnio.channels.Configurable.supportsOption.

Determine whether an option is supported on this channel.

Parameters
option:Option<?>

the option

Returns:boolean

true if it is supported

suspendReadsback to summary
public void suspendReads()

Implements org.xnio.channels.SuspendableReadChannel.suspendReads.

Doc from org.xnio.channels.SuspendableReadChannel.suspendReads.

Suspend further read notifications on this channel.

suspendWritesback to summary
public void suspendWrites()

Implements org.xnio.channels.SuspendableWriteChannel.suspendWrites.

Doc from org.xnio.channels.SuspendableWriteChannel.suspendWrites.

Suspend further write notifications on this channel.

wakeupReadsback to summary
public void wakeupReads()

Implements org.xnio.channels.SuspendableReadChannel.wakeupReads.

Doc from org.xnio.channels.SuspendableReadChannel.wakeupReads.

Resume reads on this channel, and force the read listener to be triggered even if the channel isn't actually readable.

wakeupWritesback to summary
public void wakeupWrites()

Implements org.xnio.channels.SuspendableWriteChannel.wakeupWrites.

Doc from org.xnio.channels.SuspendableWriteChannel.wakeupWrites.

Resume writes on this channel, and force the write listener to be triggered even if the channel isn't actually writable.