- java.lang.Object
-
- org.xnio.channels.AssembledChannel
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.nio.channels.Channel
,java.nio.channels.InterruptibleChannel
,CloseableChannel
,Configurable
- Direct Known Subclasses:
AssembledConnectedChannel
public class AssembledChannel extends java.lang.Object implements CloseableChannel
A closeable view over a read and write side of a suspendable channel.- Author:
- David M. Lloyd
-
-
Field Summary
-
Fields inherited from interface org.xnio.channels.Configurable
EMPTY
-
-
Constructor Summary
Constructors Constructor Description AssembledChannel(SuspendableReadChannel readChannel, SuspendableWriteChannel writeChannel)
Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close this channel.ChannelListener.Setter<? extends CloseableChannel>
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.XnioWorker
getWorker()
Get the worker for this channel.boolean
isOpen()
<T> T
setOption(Option<T> option, T value)
Set an option for this channel.boolean
supportsOption(Option<?> option)
Determine whether an option is supported on this channel.
-
-
-
Constructor Detail
-
AssembledChannel
public AssembledChannel(SuspendableReadChannel readChannel, SuspendableWriteChannel writeChannel)
Construct a new instance.- Parameters:
readChannel
- the read sidewriteChannel
- the write side
-
-
Method Detail
-
getCloseSetter
public ChannelListener.Setter<? extends CloseableChannel> getCloseSetter()
Description copied from interface:CloseableChannel
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.- Specified by:
getCloseSetter
in interfaceCloseableChannel
- Returns:
- the setter
-
getWorker
public XnioWorker getWorker()
Description copied from interface:CloseableChannel
Get the worker for this channel.- Specified by:
getWorker
in interfaceCloseableChannel
- Returns:
- the worker
-
getIoThread
public XnioIoThread getIoThread()
Description copied from interface:CloseableChannel
Get the I/O thread associated with this channel.- Specified by:
getIoThread
in interfaceCloseableChannel
- Returns:
- the I/O thread associated with this channel
-
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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.nio.channels.Channel
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceCloseableChannel
- Specified by:
close
in interfacejava.nio.channels.InterruptibleChannel
- Throws:
java.io.IOException
- if the close failed
-
isOpen
public boolean isOpen()
- Specified by:
isOpen
in interfacejava.nio.channels.Channel
-
supportsOption
public boolean supportsOption(Option<?> option)
Description copied from interface:Configurable
Determine whether an option is supported on this channel.- Specified by:
supportsOption
in interfaceConfigurable
- 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 interfaceConfigurable
- 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 interfaceConfigurable
- Type Parameters:
T
- the type of the option value- Parameters:
option
- the option to setvalue
- 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 optionjava.io.IOException
- if an I/O error occurred when modifying the option
-
-