Package org.xnio
Class Connection
java.lang.Object
org.xnio.Connection
- All Implemented Interfaces:
Closeable,AutoCloseable,Channel,InterruptibleChannel,BoundChannel,CloseableChannel,Configurable,ConnectedChannel
- Direct Known Subclasses:
MessageConnection,StreamConnection
The base for all connections.
- Author:
- David M. Lloyd
-
Field Summary
FieldsFields inherited from interface org.xnio.channels.Configurable
EMPTY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConnection(XnioIoThread thread) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()Close this channel.protected voidThe close action to perform on this connection.Get the I/O thread associated with this channel.final <A extends SocketAddress>
AgetLocalAddress(Class<A> type) Get the local address of a given type, ornullif the address is not of that type.<T> TGet the value of a channel option.final <A extends SocketAddress>
AgetPeerAddress(Class<A> type) Get the peer address of a given type, ornullif the address is not of that type.final XnioWorkerGet the worker for this channel.booleanisOpen()booleanDetermine whether reads have been shut down on this connection.booleanDetermine whether writes have been shut down on this connection.protected abstract voidIndicate to conduit handlers that reads have been closed.protected abstract voidIndicate to conduit handlers that writes have been closed.protected booleanIndicate that reads have been closed on this connection.<T> TSet an option for this channel.booleansupportsOption(Option<?> option) Determine whether an option is supported on this channel.protected booleanIndicate that writes have been closed on this connection.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xnio.channels.BoundChannel
getLocalAddressMethods inherited from interface org.xnio.channels.ConnectedChannel
getCloseSetter, getPeerAddress
-
Field Details
-
thread
-
-
Constructor Details
-
Connection
Construct a new instance.- Parameters:
thread- the I/O thread of this connection
-
-
Method Details
-
getPeerAddress
Description copied from interface:ConnectedChannelGet the peer address of a given type, ornullif the address is not of that type.- Specified by:
getPeerAddressin interfaceConnectedChannel- Parameters:
type- the address type class- Returns:
- the peer address, or
nullif unknown
-
getLocalAddress
Description copied from interface:BoundChannelGet the local address of a given type, ornullif the address is not of that type.- Specified by:
getLocalAddressin interfaceBoundChannel- Type Parameters:
A- the address type- Parameters:
type- the address type class- Returns:
- the local address, or
nullif unknown
-
getWorker
Description copied from interface:CloseableChannelGet the worker for this channel.- Specified by:
getWorkerin interfaceCloseableChannel- Returns:
- the worker
-
getIoThread
Description copied from interface:CloseableChannelGet the I/O thread associated with this channel.- Specified by:
getIoThreadin interfaceCloseableChannel- Returns:
- the I/O thread associated with this channel
-
readClosed
protected boolean readClosed()Indicate that reads have been closed on this connection.- Returns:
trueif read closure was successfully indicated;falseif this method has already been called
-
writeClosed
protected boolean writeClosed()Indicate that writes have been closed on this connection.- Returns:
trueif write closure was successfully indicated;falseif this method has already been called
-
close
Description copied from interface:CloseableChannelClose this channel. When a channel is closed, its close listener is invoked. Invoking this method more than once has no additional effect.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceCloseableChannel- Specified by:
closein interfaceInterruptibleChannel- Throws:
IOException- if the close failed
-
isReadShutdown
public boolean isReadShutdown()Determine whether reads have been shut down on this connection.- Returns:
trueif reads were shut down
-
isWriteShutdown
public boolean isWriteShutdown()Determine whether writes have been shut down on this connection.- Returns:
trueif writes were shut down
-
isOpen
public boolean isOpen() -
notifyWriteClosed
protected abstract void notifyWriteClosed()Indicate to conduit handlers that writes have been closed. -
notifyReadClosed
protected abstract void notifyReadClosed()Indicate to conduit handlers that reads have been closed. -
closeAction
The close action to perform on this connection.- Throws:
IOException- if close fails
-
supportsOption
Description copied from interface:ConfigurableDetermine whether an option is supported on this channel.- Specified by:
supportsOptionin interfaceConfigurable- Parameters:
option- the option- Returns:
trueif it is supported
-
getOption
Description copied from interface:ConfigurableGet the value of a channel option.- Specified by:
getOptionin interfaceConfigurable- Type Parameters:
T- the type of the option value- Parameters:
option- the option to get- Returns:
- the value of the option, or
nullif it is not set - Throws:
IOException- if an I/O error occurred when reading the option
-
setOption
Description copied from interface:ConfigurableSet an option for this channel. Unsupported options are ignored.- Specified by:
setOptionin 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:
IllegalArgumentException- if the value is not acceptable for this optionIOException- if an I/O error occurred when modifying the option
-