Top Description Fields Constructors Methods
org.xnio.conduits

public final Class ConduitReadableMessageChannel

extends Object
implements ReadableMessageChannel, ReadListenerSettable<ConduitReadableMessageChannel>, CloseListenerSettable<ConduitReadableMessageChannel>, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, org.xnio.channels.CloseListenerSettable, org.xnio.channels.ReadListenerSettable, org.xnio.channels.ReadableMessageChannel, org.xnio.channels.Configurable, org.xnio.channels.SuspendableReadChannel, org.xnio.channels.CloseableChannel, java.nio.channels.InterruptibleChannel, java.nio.channels.Channel, java.io.Closeable, java.lang.AutoCloseable
Imports
java.io.IOException, java.nio.ByteBuffer, java.util.concurrent.TimeUnit, org.xnio.ChannelListener, .Option, .XnioExecutor, .XnioIoThread, .XnioWorker, org.xnio.channels.CloseListenerSettable, .Configurable, .ReadListenerSettable, .ReadableMessageChannel

A readable message channel which is backed by a message source conduit.
Author
David M. Lloyd

Field Summary

Modifier and TypeField and Description
private ChannelListener<? super ConduitReadableMessageChannel>
private MessageSourceConduit
private final Configurable
private ChannelListener<? super ConduitReadableMessageChannel>

Constructor Summary

AccessConstructor and Description
public
ConduitReadableMessageChannel(final Configurable
the configurable to delegate configuration requests to
configurable
,
final MessageSourceConduit
the initial conduit to use for data transport
conduit
)

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 ConduitReadableMessageChannel

Returns:

the cloned channel
clone
()

Overrides java.lang.Object.clone.

Duplicate this channel.

public void
close()

Implements org.xnio.channels.CloseableChannel.close.

Close this channel.

public ChannelListener<? super ConduitReadableMessageChannel>
public ChannelListener.Setter<ConduitReadableMessageChannel>
getCloseSetter()

Implements org.xnio.channels.ReadableMessageChannel.getCloseSetter.

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

public MessageSourceConduit

Returns:

the underlying conduit for this channel
getConduit
()

Get the underlying conduit 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<? super ConduitReadableMessageChannel>
public ChannelListener.Setter<ConduitReadableMessageChannel>
getReadSetter()

Implements org.xnio.channels.ReadableMessageChannel.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 boolean
isOpen()

Implements java.nio.channels.Channel.isOpen.

Tells whether or not this channel is open.

public boolean
isReadResumed()

Implements org.xnio.channels.SuspendableReadChannel.isReadResumed.

Determine whether reads are resumed.

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

Implements org.xnio.channels.ReadableMessageChannel.receive.

Receive a message.

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

Implements org.xnio.channels.ReadableMessageChannel.receive.

Receive a message.

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

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
setCloseListener(final ChannelListener<? super ConduitReadableMessageChannel>
the close listener
closeListener
)

Implements org.xnio.channels.CloseListenerSettable.setCloseListener.

Set the close listener.

public void
setConduit(final MessageSourceConduit
the underlying conduit for this channel
conduit
)

Set the underlying conduit for this channel.

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
setReadListener(final ChannelListener<? super ConduitReadableMessageChannel>
the read listener
readListener
)

Implements org.xnio.channels.ReadListenerSettable.setReadListener.

Set the read listener.

public void
shutdownReads()

Implements org.xnio.channels.SuspendableReadChannel.shutdownReads.

Places this readable channel at "end of stream".

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

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

closeListenerback to summary
private ChannelListener<? super ConduitReadableMessageChannel> closeListener
conduitback to summary
private MessageSourceConduit conduit
configurableback to summary
private final Configurable configurable
readListenerback to summary
private ChannelListener<? super ConduitReadableMessageChannel> readListener

Constructor Detail

ConduitReadableMessageChannelback to summary
public ConduitReadableMessageChannel(final Configurable configurable, final MessageSourceConduit conduit)

Construct a new instance.

Parameters
configurable:Configurable

the configurable to delegate configuration requests to

conduit:MessageSourceConduit

the initial conduit to use for data transport

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
cloneback to summary
public ConduitReadableMessageChannel clone()

Overrides java.lang.Object.clone.

Duplicate this channel. Changing the delegate conduit in one channel will not affect the other.

Returns:ConduitReadableMessageChannel

the cloned channel

closeback to summary
public void close() throws IOException

Implements org.xnio.channels.CloseableChannel.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
getCloseListenerback to summary
public ChannelListener<? super ConduitReadableMessageChannel> getCloseListener()

Implements org.xnio.channels.CloseListenerSettable.getCloseListener.

Doc from org.xnio.channels.CloseListenerSettable.getCloseListener.

Get the close listener.

Returns:ChannelListener<? super ConduitReadableMessageChannel>

the close listener

getCloseSetterback to summary
public ChannelListener.Setter<ConduitReadableMessageChannel> getCloseSetter()

Implements org.xnio.channels.ReadableMessageChannel.getCloseSetter.

Doc from org.xnio.channels.ReadableMessageChannel.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<ConduitReadableMessageChannel>

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

the setter

getConduitback to summary
public MessageSourceConduit getConduit()

Get the underlying conduit for this channel.

Returns:MessageSourceConduit

the underlying conduit for this channel

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
getReadListenerback to summary
public ChannelListener<? super ConduitReadableMessageChannel> getReadListener()

Implements org.xnio.channels.ReadListenerSettable.getReadListener.

Doc from org.xnio.channels.ReadListenerSettable.getReadListener.

Get the read listener.

Returns:ChannelListener<? super ConduitReadableMessageChannel>

the read listener

getReadSetterback to summary
public ChannelListener.Setter<ConduitReadableMessageChannel> getReadSetter()

Implements org.xnio.channels.ReadableMessageChannel.getReadSetter.

Doc from org.xnio.channels.ReadableMessageChannel.getReadSetter.

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

Returns:ChannelListener.Setter<ConduitReadableMessageChannel>

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

isOpenback to summary
public boolean isOpen()

Implements java.nio.channels.Channel.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

receiveback to summary
public long receive(final ByteBuffer[] dsts, final int offset, final int length) throws IOException

Implements org.xnio.channels.ReadableMessageChannel.receive.

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

Receive a message.

Parameters
dsts:ByteBuffer[]

the buffers that will hold the message

offset:int

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

length: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
receiveback to summary
public long receive(final ByteBuffer[] dsts) throws IOException

Implements org.xnio.channels.ReadableMessageChannel.receive.

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

Receive a message.

Parameters
dsts: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 int receive(final ByteBuffer dst) throws IOException

Implements org.xnio.channels.ReadableMessageChannel.receive.

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

Receive a message.

Parameters
dst: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
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.

setCloseListenerback to summary
public void setCloseListener(final ChannelListener<? super ConduitReadableMessageChannel> closeListener)

Implements org.xnio.channels.CloseListenerSettable.setCloseListener.

Doc from org.xnio.channels.CloseListenerSettable.setCloseListener.

Set the close listener.

Parameters
closeListener:ChannelListener<? super ConduitReadableMessageChannel>

the close listener

setConduitback to summary
public void setConduit(final MessageSourceConduit conduit)

Set the underlying conduit for this channel.

Parameters
conduit:MessageSourceConduit

the underlying conduit for this channel

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
setReadListenerback to summary
public void setReadListener(final ChannelListener<? super ConduitReadableMessageChannel> readListener)

Implements org.xnio.channels.ReadListenerSettable.setReadListener.

Doc from org.xnio.channels.ReadListenerSettable.setReadListener.

Set the read listener.

Parameters
readListener:ChannelListener<? super ConduitReadableMessageChannel>

the read listener

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

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.