Top Description Fields Constructors Methods
org.xnio.conduits

public final Class ConduitWritableMessageChannel

extends Object
implements WritableMessageChannel, WriteListenerSettable<ConduitWritableMessageChannel>, CloseListenerSettable<ConduitWritableMessageChannel>, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, org.xnio.channels.CloseListenerSettable, org.xnio.channels.WriteListenerSettable, org.xnio.channels.WritableMessageChannel, org.xnio.channels.Configurable, org.xnio.channels.SuspendableWriteChannel, 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, .WritableMessageChannel, .WriteListenerSettable

A writable message channel which is backed by a message sink conduit.
Author
David M. Lloyd

Field Summary

Modifier and TypeField and Description
private ChannelListener<? super ConduitWritableMessageChannel>
private MessageSinkConduit
private final Configurable
private ChannelListener<? super ConduitWritableMessageChannel>

Constructor Summary

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

Construct a new instance.

Method Summary

Modifier and TypeMethod and Description
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 ConduitWritableMessageChannel

Returns:

the cloned channel
clone
()

Overrides java.lang.Object.clone.

Duplicate this channel.

public void
close()

Implements org.xnio.channels.SuspendableWriteChannel.close.

Close this channel.

public boolean
flush()

Implements org.xnio.channels.SuspendableWriteChannel.flush.

Flush any waiting partial send or write.

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

Implements org.xnio.channels.WritableMessageChannel.getCloseSetter.

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

public MessageSinkConduit

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 XnioWorker
getWorker()

Implements org.xnio.channels.CloseableChannel.getWorker.

Get the worker for this channel.

public ChannelListener<? super ConduitWritableMessageChannel>
public ChannelListener.Setter<ConduitWritableMessageChannel>
getWriteSetter()

Implements org.xnio.channels.WritableMessageChannel.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 org.xnio.channels.SuspendableWriteChannel.isOpen.

Determine whether this channel is open.

public boolean
isWriteResumed()

Implements org.xnio.channels.SuspendableWriteChannel.isWriteResumed.

Determine whether writes are resumed.

public void
resumeWrites()

Implements org.xnio.channels.SuspendableWriteChannel.resumeWrites.

Resume writes on this channel.

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

Implements org.xnio.channels.WritableMessageChannel.send.

Send a complete message.

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

Implements org.xnio.channels.WritableMessageChannel.send.

Send a complete message.

public boolean
send(final ByteBuffer[]
the buffers holding the message to send
dsts
,
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 void
setCloseListener(final ChannelListener<? super ConduitWritableMessageChannel>
the close listener
closeListener
)

Implements org.xnio.channels.CloseListenerSettable.setCloseListener.

Set the close listener.

public void
setConduit(final MessageSinkConduit
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
setWriteListener(final ChannelListener<? super ConduitWritableMessageChannel>
the write listener
writeListener
)

Implements org.xnio.channels.WriteListenerSettable.setWriteListener.

Set the write listener.

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
suspendWrites()

Implements org.xnio.channels.SuspendableWriteChannel.suspendWrites.

Suspend further write notifications on this channel.

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:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

closeListenerback to summary
private ChannelListener<? super ConduitWritableMessageChannel> closeListener
conduitback to summary
private MessageSinkConduit conduit
configurableback to summary
private final Configurable configurable
writeListenerback to summary
private ChannelListener<? super ConduitWritableMessageChannel> writeListener

Constructor Detail

ConduitWritableMessageChannelback to summary
public ConduitWritableMessageChannel(final Configurable configurable, final MessageSinkConduit conduit)

Construct a new instance.

Parameters
configurable:Configurable

the configurable to delegate configuration requests to

conduit:MessageSinkConduit

the initial conduit to use for data transport

Method Detail

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

Overrides java.lang.Object.clone.

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

Returns:ConduitWritableMessageChannel

the cloned channel

closeback to summary
public void close() throws IOException

Implements org.xnio.channels.SuspendableWriteChannel.close.

Doc from org.xnio.channels.SuspendableWriteChannel.close.

Close this channel. If data has been written but not flushed, that data may be discarded, depending on the channel implementation. 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
getCloseListenerback to summary
public ChannelListener<? super ConduitWritableMessageChannel> getCloseListener()

Implements org.xnio.channels.CloseListenerSettable.getCloseListener.

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

Get the close listener.

Returns:ChannelListener<? super ConduitWritableMessageChannel>

the close listener

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

Implements org.xnio.channels.WritableMessageChannel.getCloseSetter.

Doc from org.xnio.channels.WritableMessageChannel.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<ConduitWritableMessageChannel>

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

the setter

getConduitback to summary
public MessageSinkConduit getConduit()

Get the underlying conduit for this channel.

Returns:MessageSinkConduit

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

getWriteListenerback to summary
public ChannelListener<? super ConduitWritableMessageChannel> getWriteListener()

Implements org.xnio.channels.WriteListenerSettable.getWriteListener.

Doc from org.xnio.channels.WriteListenerSettable.getWriteListener.

Get the write listener.

Returns:ChannelListener<? super ConduitWritableMessageChannel>

the write listener

getWriteSetterback to summary
public ChannelListener.Setter<ConduitWritableMessageChannel> getWriteSetter()

Implements org.xnio.channels.WritableMessageChannel.getWriteSetter.

Doc from org.xnio.channels.WritableMessageChannel.getWriteSetter.

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

Returns:ChannelListener.Setter<ConduitWritableMessageChannel>

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 org.xnio.channels.SuspendableWriteChannel.isOpen.

Doc from org.xnio.channels.SuspendableWriteChannel.isOpen.

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.

Returns:boolean

true if the channel is open, false otherwise

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

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 dst) throws IOException

Implements org.xnio.channels.WritableMessageChannel.send.

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

Send a complete message.

Parameters
dst: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[] srcs) throws IOException

Implements org.xnio.channels.WritableMessageChannel.send.

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

Send a complete message.

Parameters
srcs: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[] dsts, 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
dsts: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
setCloseListenerback to summary
public void setCloseListener(final ChannelListener<? super ConduitWritableMessageChannel> closeListener)

Implements org.xnio.channels.CloseListenerSettable.setCloseListener.

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

Set the close listener.

Parameters
closeListener:ChannelListener<? super ConduitWritableMessageChannel>

the close listener

setConduitback to summary
public void setConduit(final MessageSinkConduit conduit)

Set the underlying conduit for this channel.

Parameters
conduit:MessageSinkConduit

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
setWriteListenerback to summary
public void setWriteListener(final ChannelListener<? super ConduitWritableMessageChannel> writeListener)

Implements org.xnio.channels.WriteListenerSettable.setWriteListener.

Doc from org.xnio.channels.WriteListenerSettable.setWriteListener.

Set the write listener.

Parameters
writeListener:ChannelListener<? super ConduitWritableMessageChannel>

the write listener

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

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.

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.