Top Description Fields Constructors Methods
org.xnio

public abstract Class Connection

extends Object
implements CloseableChannel, ConnectedChannel
Class Inheritance
All Implemented Interfaces
org.xnio.channels.ConnectedChannel, org.xnio.channels.BoundChannel, org.xnio.channels.CloseableChannel, org.xnio.channels.Configurable, java.nio.channels.InterruptibleChannel, java.nio.channels.Channel, java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
org.xnio.StreamConnection, org.xnio.MessageConnection
Imports
java.io.IOException, java.net.SocketAddress, java.util.concurrent.atomic.AtomicIntegerFieldUpdater, org.xnio.channels.CloseableChannel, .ConnectedChannel

The base for all connections.
Author
David M. Lloyd

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private volatile int
private static final AtomicIntegerFieldUpdater<Connection>
protected final XnioIoThread

Constructor Summary

AccessConstructor and Description
protected
Connection(final XnioIoThread
the I/O thread of this connection
thread
)

Construct a new instance.

Method Summary

Modifier and TypeMethod and Description
private static <A extends SocketAddress> A
castAddress(final Class<A> type, SocketAddress address)

public final void
close()

Implements org.xnio.channels.CloseableChannel.close.

Close this channel.

protected void
closeAction()

The close action to perform on this connection.

public XnioIoThread
getIoThread()

Implements org.xnio.channels.CloseableChannel.getIoThread.

Get the I/O thread associated with this channel.

public final <A extends SocketAddress> A
getLocalAddress(final Class<A>
the address type class
type
)

Implements org.xnio.channels.BoundChannel.getLocalAddress.

Get the local address of a given type, or null if the address is not of that type.

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 final <A extends SocketAddress> A
getPeerAddress(final Class<A>
the address type class
type
)

Implements org.xnio.channels.ConnectedChannel.getPeerAddress.

Get the peer address of a given type, or null if the address is not of that type.

public final XnioWorker
getWorker()

Implements org.xnio.channels.CloseableChannel.getWorker.

Get the worker for this channel.

pack-priv abstract void
public boolean
isOpen()

Implements java.nio.channels.Channel.isOpen.

Tells whether or not this channel is open.

public boolean

Returns:

true if reads were shut down
isReadShutdown
()

Determine whether reads have been shut down on this connection.

public boolean

Returns:

true if writes were shut down
isWriteShutdown
()

Determine whether writes have been shut down on this connection.

protected abstract void
notifyReadClosed()

Indicate to conduit handlers that reads have been closed.

protected abstract void
notifyWriteClosed()

Indicate to conduit handlers that writes have been closed.

protected boolean

Returns:

true if read closure was successfully indicated; false if this method has already been called
readClosed
()

Indicate that reads have been closed on this connection.

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 boolean
supportsOption(final Option<?>
the option
option
)

Implements org.xnio.channels.Configurable.supportsOption.

Determine whether an option is supported on this channel.

protected boolean

Returns:

true if write closure was successfully indicated; false if this method has already been called
writeClosed
()

Indicate that writes have been closed on this connection.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FLAG_READ_CLOSEDback to summary
private static final int FLAG_READ_CLOSED
FLAG_WRITE_CLOSEDback to summary
private static final int FLAG_WRITE_CLOSED
stateback to summary
private volatile int state
Annotations
@SuppressWarnings:unused
stateUpdaterback to summary
private static final AtomicIntegerFieldUpdater<Connection> stateUpdater
threadback to summary
protected final XnioIoThread thread

Constructor Detail

Connectionback to summary
protected Connection(final XnioIoThread thread)

Construct a new instance.

Parameters
thread:XnioIoThread

the I/O thread of this connection

Method Detail

castAddressback to summary
private static <A extends SocketAddress> A castAddress(final Class<A> type, SocketAddress address)
closeback to summary
public final 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
closeActionback to summary
protected void closeAction() throws IOException

The close action to perform on this connection.

Exceptions
IOException:
if close fails
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

getLocalAddressback to summary
public final <A extends SocketAddress> A getLocalAddress(final Class<A> type)

Implements org.xnio.channels.BoundChannel.getLocalAddress.

Doc from org.xnio.channels.BoundChannel.getLocalAddress.

Get the local address of a given type, or null if the address is not of that type.

Parameters
<A>
the address type
type:Class<A>

the address type class

Returns:A

the local address, or null if unknown

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
getPeerAddressback to summary
public final <A extends SocketAddress> A getPeerAddress(final Class<A> type)

Implements org.xnio.channels.ConnectedChannel.getPeerAddress.

Doc from org.xnio.channels.ConnectedChannel.getPeerAddress.

Get the peer address of a given type, or null if the address is not of that type.

Parameters
type:Class<A>

the address type class

Returns:A

the peer address, or null if unknown

getWorkerback to summary
public final 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

invokeCloseListenerback to summary
pack-priv abstract void invokeCloseListener()
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

isReadShutdownback to summary
public boolean isReadShutdown()

Determine whether reads have been shut down on this connection.

Returns:boolean

true if reads were shut down

isWriteShutdownback to summary
public boolean isWriteShutdown()

Determine whether writes have been shut down on this connection.

Returns:boolean

true if writes were shut down

notifyReadClosedback to summary
protected abstract void notifyReadClosed()

Indicate to conduit handlers that reads have been closed.

notifyWriteClosedback to summary
protected abstract void notifyWriteClosed()

Indicate to conduit handlers that writes have been closed.

readClosedback to summary
protected boolean readClosed()

Indicate that reads have been closed on this connection.

Returns:boolean

true if read closure was successfully indicated; false if this method has already been called

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

writeClosedback to summary
protected boolean writeClosed()

Indicate that writes have been closed on this connection.

Returns:boolean

true if write closure was successfully indicated; false if this method has already been called