public class AssembledMessageChannel extends java.lang.Object implements MessageChannel
EMPTY| Constructor and Description |
|---|
AssembledMessageChannel(CloseableChannel closeable,
ReadableMessageChannel readable,
WritableMessageChannel writable)
Construct a new instance.
|
AssembledMessageChannel(ReadableMessageChannel readable,
WritableMessageChannel writable)
Construct a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
awaitReadable()
Block until this channel becomes readable again.
|
void |
awaitReadable(long time,
java.util.concurrent.TimeUnit timeUnit)
Block until this channel becomes readable again, or until the timeout expires.
|
void |
awaitWritable()
Block until this channel becomes writable again.
|
void |
awaitWritable(long time,
java.util.concurrent.TimeUnit timeUnit)
Block until this channel becomes writable again, or until the timeout expires.
|
void |
close()
Close this channel.
|
boolean |
flush()
Flush any waiting partial send or write.
|
ChannelListener.Setter<? extends AssembledMessageChannel> |
getCloseSetter()
Get the setter which can be used to change the close listener for this channel.
|
XnioIoThread |
getIoThread()
Get the I/O thread associated with this channel.
|
<T> T |
getOption(Option<T> option)
Get the value of a channel option.
|
ChannelListener.Setter<? extends AssembledMessageChannel> |
getReadSetter()
Get the setter which can be used to change the read listener for this channel.
|
XnioExecutor |
getReadThread()
Deprecated.
|
XnioWorker |
getWorker()
Get the worker for this channel.
|
ChannelListener.Setter<? extends AssembledMessageChannel> |
getWriteSetter()
Get the setter which can be used to change the write listener for this channel.
|
XnioExecutor |
getWriteThread()
Deprecated.
|
boolean |
isOpen()
Determine whether this channel is open.
|
boolean |
isReadResumed()
Determine whether reads are resumed.
|
boolean |
isWriteResumed()
Determine whether writes are resumed.
|
int |
receive(java.nio.ByteBuffer buffer)
Receive a message.
|
long |
receive(java.nio.ByteBuffer[] buffers)
Receive a message.
|
long |
receive(java.nio.ByteBuffer[] buffers,
int offs,
int len)
Receive a message.
|
void |
resumeReads()
Resume reads on this channel.
|
void |
resumeWrites()
Resume writes on this channel.
|
boolean |
send(java.nio.ByteBuffer buffer)
Send a complete message.
|
boolean |
send(java.nio.ByteBuffer[] buffers)
Send a complete message.
|
boolean |
send(java.nio.ByteBuffer[] buffers,
int offs,
int len)
Send a complete message.
|
boolean |
sendFinal(java.nio.ByteBuffer buffer)
Send a complete message.
|
boolean |
sendFinal(java.nio.ByteBuffer[] buffers)
Send a complete message.
|
boolean |
sendFinal(java.nio.ByteBuffer[] buffers,
int offs,
int len)
Send a complete message.
|
<T> T |
setOption(Option<T> option,
T value)
Set an option for this channel.
|
void |
shutdownReads()
Places this readable channel at "end of stream".
|
void |
shutdownWrites()
Indicate that writing is complete for this channel.
|
boolean |
supportsOption(Option<?> option)
Determine whether an option is supported on this channel.
|
void |
suspendReads()
Suspend further read notifications on this channel.
|
void |
suspendWrites()
Suspend further write notifications on this channel.
|
void |
wakeupReads()
Resume reads on this channel, and force the read listener to be triggered even if the
channel isn't actually readable. |
void |
wakeupWrites()
Resume writes on this channel, and force the write listener to be triggered even if the
channel isn't actually writable. |
public AssembledMessageChannel(CloseableChannel closeable, ReadableMessageChannel readable, WritableMessageChannel writable)
closeable - the single central closeable channelreadable - the read channelwritable - the write channelpublic AssembledMessageChannel(ReadableMessageChannel readable, WritableMessageChannel writable)
readable - the read channelwritable - the write channelpublic XnioIoThread getIoThread()
CloseableChannelgetIoThread in interface CloseableChannelpublic ChannelListener.Setter<? extends AssembledMessageChannel> getReadSetter()
MessageChannelgetReadSetter in interface MessageChannelgetReadSetter in interface ReadableMessageChannelgetReadSetter in interface SuspendableChannelgetReadSetter in interface SuspendableReadChannelpublic void suspendReads()
SuspendableReadChannelsuspendReads in interface SuspendableReadChannelpublic void resumeReads()
SuspendableReadChannelresumeReads in interface SuspendableReadChannelpublic boolean isReadResumed()
SuspendableReadChannelisReadResumed in interface SuspendableReadChanneltrue if reads are resumed, false if reads are suspendedpublic void wakeupReads()
SuspendableReadChannelResume reads on this channel, and force the read listener to be triggered even if the
channel isn't actually readable.wakeupReads in interface SuspendableReadChannelpublic void shutdownReads()
throws java.io.IOException
SuspendableReadChannelCloseableChannel.close() to be called automatically.shutdownReads in interface SuspendableReadChanneljava.io.IOException - if an I/O error occurspublic void awaitReadable()
throws java.io.IOException
SuspendableReadChannelawaitReadable in interface SuspendableReadChanneljava.io.InterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as welljava.io.IOException - if an I/O error occurspublic void awaitReadable(long time,
java.util.concurrent.TimeUnit timeUnit)
throws java.io.IOException
SuspendableReadChannelawaitReadable in interface SuspendableReadChanneltime - the time to waittimeUnit - the time unitjava.io.InterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as welljava.io.IOException - if an I/O error occurs@Deprecated public XnioExecutor getReadThread()
SuspendableReadChannelgetReadThread in interface SuspendableReadChannelnull if none is configured or availablepublic int receive(java.nio.ByteBuffer buffer)
throws java.io.IOException
ReadableMessageChannelreceive in interface ReadableMessageChannelbuffer - the buffer that will hold the messagejava.io.IOException - if an I/O error occurspublic long receive(java.nio.ByteBuffer[] buffers)
throws java.io.IOException
ReadableMessageChannelreceive in interface ReadableMessageChannelbuffers - the buffers that will hold the messagejava.io.IOException - if an I/O error occurspublic long receive(java.nio.ByteBuffer[] buffers,
int offs,
int len)
throws java.io.IOException
ReadableMessageChannelreceive in interface ReadableMessageChannelbuffers - the buffers that will hold the messageoffs - the offset into the array of buffers of the first buffer to read intolen - the number of buffers to filljava.io.IOException - if an I/O error occurspublic ChannelListener.Setter<? extends AssembledMessageChannel> getWriteSetter()
MessageChannelgetWriteSetter in interface MessageChannelgetWriteSetter in interface SuspendableChannelgetWriteSetter in interface SuspendableWriteChannelgetWriteSetter in interface WritableMessageChannelpublic void suspendWrites()
SuspendableWriteChannelsuspendWrites in interface SuspendableWriteChannelpublic void resumeWrites()
SuspendableWriteChannelresumeWrites in interface SuspendableWriteChannelpublic boolean isWriteResumed()
SuspendableWriteChannelisWriteResumed in interface SuspendableWriteChanneltrue if writes are resumed, false if writes are suspendedpublic void wakeupWrites()
SuspendableWriteChannelResume writes on this channel, and force the write listener to be triggered even if the
channel isn't actually writable.wakeupWrites in interface SuspendableWriteChannelpublic void shutdownWrites()
throws java.io.IOException
SuspendableWriteChannelSuspendableWriteChannel.flush() method; once this is done, if the read side of the channel was shut down, the channel will
automatically close.shutdownWrites in interface SuspendableWriteChanneljava.io.IOException - if an I/O error occurspublic void awaitWritable()
throws java.io.IOException
SuspendableWriteChannelawaitWritable in interface SuspendableWriteChanneljava.io.InterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as welljava.io.IOException - if an I/O error occurspublic void awaitWritable(long time,
java.util.concurrent.TimeUnit timeUnit)
throws java.io.IOException
SuspendableWriteChannelawaitWritable in interface SuspendableWriteChanneltime - the time to waittimeUnit - the time unitjava.io.InterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as welljava.io.IOException - if an I/O error occurs@Deprecated public XnioExecutor getWriteThread()
SuspendableWriteChannelgetWriteThread in interface SuspendableWriteChannelnull if none is configured or availablepublic boolean send(java.nio.ByteBuffer buffer)
throws java.io.IOException
WritableMessageChannelsend in interface WritableMessageChannelbuffer - the message to sendtrue if the message was sent, or false if it would blockjava.io.IOException - if an I/O error occurspublic boolean send(java.nio.ByteBuffer[] buffers)
throws java.io.IOException
WritableMessageChannelsend in interface WritableMessageChannelbuffers - the buffers holding the message to sendtrue if the message was sent, or false if it would blockjava.io.IOException - if an I/O error occurspublic boolean send(java.nio.ByteBuffer[] buffers,
int offs,
int len)
throws java.io.IOException
WritableMessageChannelsend in interface WritableMessageChannelbuffers - the buffers holding the message to sendoffs - the offset into the buffer array of the first bufferlen - the number of buffers that contain data to sendtrue if the message was sent, or false if it would blockjava.io.IOException - if an I/O error occurspublic boolean sendFinal(java.nio.ByteBuffer buffer)
throws java.io.IOException
WritableMessageChannelsendFinal in interface WritableMessageChannelbuffer - the message to sendtrue if the message was sent, or false if it would blockjava.io.IOException - if an I/O error occurspublic boolean sendFinal(java.nio.ByteBuffer[] buffers)
throws java.io.IOException
WritableMessageChannelsendFinal in interface WritableMessageChannelbuffers - the buffers holding the message to sendtrue if the message was sent, or false if it would blockjava.io.IOException - if an I/O error occurspublic boolean sendFinal(java.nio.ByteBuffer[] buffers,
int offs,
int len)
throws java.io.IOException
WritableMessageChannelsendFinal in interface WritableMessageChannelbuffers - the buffers holding the message to sendoffs - the offset into the buffer array of the first bufferlen - the number of buffers that contain data to sendtrue if the message was sent, or false if it would blockjava.io.IOException - if an I/O error occurspublic boolean flush()
throws java.io.IOException
SuspendableWriteChanneltrue. 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.flush in interface SuspendableWriteChanneltrue if the message was flushed, or false if the result would blockjava.io.IOException - if an I/O error occurspublic ChannelListener.Setter<? extends AssembledMessageChannel> getCloseSetter()
MessageChannelgetCloseSetter in interface CloseableChannelgetCloseSetter in interface MessageChannelgetCloseSetter in interface ReadableMessageChannelgetCloseSetter in interface SuspendableChannelgetCloseSetter in interface SuspendableReadChannelgetCloseSetter in interface SuspendableWriteChannelgetCloseSetter in interface WritableMessageChannelpublic XnioWorker getWorker()
CloseableChannelgetWorker in interface CloseableChannelpublic void close()
throws java.io.IOException
CloseableChannelclose in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface java.nio.channels.Channelclose in interface java.nio.channels.InterruptibleChannelclose in interface CloseableChannelclose in interface SuspendableWriteChanneljava.io.IOException - if the close failedpublic boolean isOpen()
SuspendableWriteChannelfalse if all directions are shut down,
even if there is unflushed write data pending.isOpen in interface java.nio.channels.ChannelisOpen in interface SuspendableWriteChanneltrue if the channel is open, false otherwisepublic boolean supportsOption(Option<?> option)
ConfigurablesupportsOption in interface Configurableoption - the optiontrue if it is supportedpublic <T> T getOption(Option<T> option) throws java.io.IOException
ConfigurablegetOption in interface ConfigurableT - the type of the option valueoption - the option to getnull if it is not setjava.io.IOException - if an I/O error occurred when reading the optionpublic <T> T setOption(Option<T> option, T value) throws java.lang.IllegalArgumentException, java.io.IOException
ConfigurablesetOption in interface ConfigurableT - the type of the option valueoption - the option to setvalue - the value of the option to setjava.lang.IllegalArgumentException - if the value is not acceptable for this optionjava.io.IOException - if an I/O error occurred when modifying the optionCopyright © 2016 JBoss, a division of Red Hat, Inc.