io.undertow.server

## Class AbstractServerConnection

- java.lang.Object
- - io.undertow.util.AbstractAttachable
  - - io.undertow.server.ServerConnection
    - - io.undertow.server.AbstractServerConnection

All Implemented Interfaces:
  Attachable, Closeable, AutoCloseable, Channel, InterruptibleChannel, org.xnio.channels.BoundChannel, org.xnio.channels.CloseableChannel, org.xnio.channels.Configurable, org.xnio.channels.ConnectedChannel

Direct Known Subclasses:
  AjpServerConnection, HttpServerConnection

    public abstract class AbstractServerConnection
    extends ServerConnection

### Nested Class Summary

Nested Classes
`static class` `AbstractServerConnection.ConduitState`

### Nested classes/interfaces inherited from class io.undertow.server.ServerConnection

`ServerConnection.CloseListener`

### Field Summary

Fields
`protected ByteBufferPool` `bufferPool`
`protected org.xnio.StreamConnection` `channel`
`protected List<ServerConnection.CloseListener>` `closeListeners`
`protected io.undertow.server.AbstractServerConnection.CloseSetter` `closeSetter`
`protected HttpServerExchange` `current`
`protected PooledByteBuffer` `extraBytes` Any extra bytes that were read from the channel.
`protected org.xnio.conduits.StreamSinkConduit` `originalSinkConduit`
`protected org.xnio.conduits.StreamSourceConduit` `originalSourceConduit`
`protected HttpHandler` `rootHandler`
`protected org.xnio.OptionMap` `undertowOptions`

### Fields inherited from interface org.xnio.channels.Configurable

`EMPTY`

### Constructor Summary

Constructors
Constructor and Description
`AbstractServerConnection(org.xnio.StreamConnection channel, ByteBufferPool bufferPool, HttpHandler rootHandler, org.xnio.OptionMap undertowOptions, int bufferSize)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `addCloseListener(ServerConnection.CloseListener listener)` Adds a close listener, than will be invoked with the connection is closed
`void` `clearChannel()` Resets the channel to its original state, effectively disabling all current conduit wrappers.
`void` `close()`
`org.xnio.Pool<ByteBuffer>` `getBufferPool()`
`int` `getBufferSize()`
`ByteBufferPool` `getByteBufferPool()` Get the buffer pool for this connection.
`org.xnio.StreamConnection` `getChannel()` Get the underlying channel.
`org.xnio.ChannelListener.Setter<ServerConnection>` `getCloseSetter()`
`PooledByteBuffer` `getExtraBytes()`
`org.xnio.XnioIoThread` `getIoThread()`
`SocketAddress` `getLocalAddress()`
`<A extends SocketAddress> A` `getLocalAddress(Class<A> type)`
`<T> T` `getOption(org.xnio.Option<T> option)`
`org.xnio.conduits.StreamSinkConduit` `getOriginalSinkConduit()`
`org.xnio.conduits.StreamSourceConduit` `getOriginalSourceConduit()`
`SocketAddress` `getPeerAddress()` Returns the actual address of the remote connection.
`<A extends SocketAddress> A` `getPeerAddress(Class<A> type)` Returns the actual address of the remote connection.
`HttpHandler` `getRootHandler()` Get the root HTTP handler for this connection.
`protected org.xnio.conduits.ConduitStreamSinkChannel` `getSinkChannel()`
`protected org.xnio.conduits.ConduitStreamSourceChannel` `getSourceChannel()`
`org.xnio.OptionMap` `getUndertowOptions()`
`org.xnio.XnioWorker` `getWorker()`
`boolean` `isOpen()`
`protected void` `maxEntitySizeUpdated(HttpServerExchange exchange)` Callback that is invoked if the max entity size is updated.
`AbstractServerConnection.ConduitState` `resetChannel()` Resets the channel to its original state, effectively disabling all current conduit wrappers.
`void` `restoreChannel(AbstractServerConnection.ConduitState state)` Restores the channel conduits to a previous state.
`void` `setExtraBytes(PooledByteBuffer extraBytes)`
`<T> T` `setOption(org.xnio.Option<T> option, T value)`
`protected void` `setUpgradeListener(HttpUpgradeListener upgradeListener)`
`protected static org.xnio.conduits.StreamSinkConduit` `sink(AbstractServerConnection.ConduitState state)`
`protected static org.xnio.conduits.StreamSourceConduit` `source(AbstractServerConnection.ConduitState state)`
`boolean` `supportsOption(org.xnio.Option<?> option)`

### Methods inherited from class io.undertow.server.ServerConnection

`exchangeComplete, getSinkConduit, getSslSession, getSslSessionInfo, getTransportProtocol, isConnectSupported, isContinueResponseSupported, isPushSupported, isRequestTrailerFieldsSupported, isUpgradeSupported, pushResource, pushResource, sendOutOfBandResponse, setConnectListener, setSslSessionInfo, terminateRequestChannel, upgradeChannel`

### Methods inherited from class io.undertow.util.AbstractAttachable

`addToAttachmentList, createAttachmentMap, getAttachment, getAttachmentList, putAttachment, removeAttachment`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### channel

    protected final org.xnio.StreamConnection channel

#### closeSetter

    protected final io.undertow.server.AbstractServerConnection.CloseSetter closeSetter

#### bufferPool

    protected final ByteBufferPool bufferPool

#### rootHandler

    protected final HttpHandler rootHandler

#### undertowOptions

    protected final org.xnio.OptionMap undertowOptions

#### originalSourceConduit

    protected final org.xnio.conduits.StreamSourceConduit originalSourceConduit

#### originalSinkConduit

    protected final org.xnio.conduits.StreamSinkConduit originalSinkConduit

#### closeListeners

    protected final List<ServerConnection.CloseListener> closeListeners

#### current

    protected HttpServerExchange current

#### extraBytes

    protected PooledByteBuffer extraBytes

Any extra bytes that were read from the channel. This could be data for this requests, or the next response.

### Constructor Detail

#### AbstractServerConnection

    public AbstractServerConnection(org.xnio.StreamConnection channel,
                                    ByteBufferPool bufferPool,
                                    HttpHandler rootHandler,
                                    org.xnio.OptionMap undertowOptions,
                                    int bufferSize)

### Method Detail

#### getBufferPool

    public org.xnio.Pool<ByteBuffer> getBufferPool()

Specified by:
  `getBufferPool` in class `ServerConnection`
Returns:
  The connections buffer pool

#### getRootHandler

    public HttpHandler getRootHandler()

Get the root HTTP handler for this connection.

Returns:
  the root HTTP handler for this connection

#### getByteBufferPool

    public ByteBufferPool getByteBufferPool()

Get the buffer pool for this connection.

Specified by:
  `getByteBufferPool` in class `ServerConnection`
Returns:
  the buffer pool for this connection

#### getChannel

    public org.xnio.StreamConnection getChannel()

Get the underlying channel.

Returns:
  the underlying channel

#### getCloseSetter

    public org.xnio.ChannelListener.Setter<ServerConnection> getCloseSetter()

#### getWorker

    public org.xnio.XnioWorker getWorker()

Specified by:
  `getWorker` in interface `org.xnio.channels.CloseableChannel`
Specified by:
  `getWorker` in class `ServerConnection`
Returns:
  The connections worker

#### getIoThread

    public org.xnio.XnioIoThread getIoThread()

Specified by:
  `getIoThread` in interface `org.xnio.channels.CloseableChannel`
Specified by:
  `getIoThread` in class `ServerConnection`
Returns:
  The IO thread associated with the connection

#### isOpen

    public boolean isOpen()

Specified by:
  `isOpen` in interface `Channel`
Specified by:
  `isOpen` in class `ServerConnection`
Returns:
  true if the connection is open

#### supportsOption

    public boolean supportsOption(org.xnio.Option<?> option)

Specified by:
  `supportsOption` in interface `org.xnio.channels.Configurable`
Specified by:
  `supportsOption` in class `ServerConnection`

#### getOption

    public <T> T getOption(org.xnio.Option<T> option)
                    throws IOException

Specified by:
  `getOption` in interface `org.xnio.channels.Configurable`
Specified by:
  `getOption` in class `ServerConnection`
Throws:
  `IOException`

#### setOption

    public <T> T setOption(org.xnio.Option<T> option,
                           T value)
                    throws IllegalArgumentException,
                           IOException

Specified by:
  `setOption` in interface `org.xnio.channels.Configurable`
Specified by:
  `setOption` in class `ServerConnection`
Throws:
  `IllegalArgumentException`
  `IOException`

#### close

    public void close()
               throws IOException

Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Channel`
Specified by:
  `close` in interface `InterruptibleChannel`
Specified by:
  `close` in interface `org.xnio.channels.CloseableChannel`
Specified by:
  `close` in class `ServerConnection`
Throws:
  `IOException`

#### getPeerAddress

    public SocketAddress getPeerAddress()

Description copied from class: `ServerConnection`
Returns the actual address of the remote connection. This will not take things like X-Forwarded-for into account.

Specified by:
  `getPeerAddress` in interface `org.xnio.channels.ConnectedChannel`
Specified by:
  `getPeerAddress` in class `ServerConnection`
Returns:
  The address of the remote peer

#### getPeerAddress

    public <A extends SocketAddress> A getPeerAddress(Class<A> type)

Description copied from class: `ServerConnection`
Returns the actual address of the remote connection. This will not take things like X-Forwarded-for into account.

Specified by:
  `getPeerAddress` in interface `org.xnio.channels.ConnectedChannel`
Specified by:
  `getPeerAddress` in class `ServerConnection`
Type Parameters:
  `A` - The address type
Parameters:
  `type` - The type of address to return
Returns:
  The remote endpoint address

#### getLocalAddress

    public SocketAddress getLocalAddress()

Specified by:
  `getLocalAddress` in interface `org.xnio.channels.BoundChannel`
Specified by:
  `getLocalAddress` in class `ServerConnection`

#### getLocalAddress

    public <A extends SocketAddress> A getLocalAddress(Class<A> type)

Specified by:
  `getLocalAddress` in interface `org.xnio.channels.BoundChannel`
Specified by:
  `getLocalAddress` in class `ServerConnection`

#### getUndertowOptions

    public org.xnio.OptionMap getUndertowOptions()

Specified by:
  `getUndertowOptions` in class `ServerConnection`

#### getBufferSize

    public int getBufferSize()

Specified by:
  `getBufferSize` in class `ServerConnection`
Returns:
  The size of the buffers allocated by the buffer pool

#### getExtraBytes

    public PooledByteBuffer getExtraBytes()

#### setExtraBytes

    public void setExtraBytes(PooledByteBuffer extraBytes)

#### getOriginalSourceConduit

    public org.xnio.conduits.StreamSourceConduit getOriginalSourceConduit()

Returns:
  The original source conduit

#### getOriginalSinkConduit

    public org.xnio.conduits.StreamSinkConduit getOriginalSinkConduit()

Returns:
  The original underlying sink conduit

#### resetChannel

    public AbstractServerConnection.ConduitState resetChannel()

Resets the channel to its original state, effectively disabling all current conduit wrappers. The current state is encapsulated inside a `AbstractServerConnection.ConduitState` object that can be used the restore the channel.

Returns:
  An opaque representation of the previous channel state

#### clearChannel

    public void clearChannel()

Resets the channel to its original state, effectively disabling all current conduit wrappers. The current state is lost.

#### restoreChannel

    public void restoreChannel(AbstractServerConnection.ConduitState state)

Restores the channel conduits to a previous state.

Parameters:
  `state` - The original state
See Also:
  `resetChannel()`

#### sink

    protected static org.xnio.conduits.StreamSinkConduit sink(AbstractServerConnection.ConduitState state)

#### source

    protected static org.xnio.conduits.StreamSourceConduit source(AbstractServerConnection.ConduitState state)

#### addCloseListener

    public void addCloseListener(ServerConnection.CloseListener listener)

Description copied from class: `ServerConnection`
Adds a close listener, than will be invoked with the connection is closed

Specified by:
  `addCloseListener` in class `ServerConnection`
Parameters:
  `listener` - The close listener

#### getSinkChannel

    protected org.xnio.conduits.ConduitStreamSinkChannel getSinkChannel()

Specified by:
  `getSinkChannel` in class `ServerConnection`

#### getSourceChannel

    protected org.xnio.conduits.ConduitStreamSourceChannel getSourceChannel()

Specified by:
  `getSourceChannel` in class `ServerConnection`

#### setUpgradeListener

    protected void setUpgradeListener(HttpUpgradeListener upgradeListener)

Specified by:
  `setUpgradeListener` in class `ServerConnection`

#### maxEntitySizeUpdated

    protected void maxEntitySizeUpdated(HttpServerExchange exchange)

Description copied from class: `ServerConnection`
Callback that is invoked if the max entity size is updated.

Specified by:
  `maxEntitySizeUpdated` in class `ServerConnection`
Parameters:
  `exchange` - The current exchange