public class DelegatingConnectionContext extends java.lang.Object implements ConnectionContext
ConnectionContext
implementation that delegates all calls to a provided ConnectionContext
. Any of
the methods can be overridden by implementations to change the behavior.ConnectionContext.Protocol
Constructor and Description |
---|
DelegatingConnectionContext(ConnectionContext delegate)
New instance.
|
Modifier and Type | Method and Description |
---|---|
Completable |
closeAsync()
Used to close/shutdown a resource.
|
Completable |
closeAsyncGracefully()
Used to close/shutdown a resource, similar to
AsyncCloseable.closeAsync() , but attempts to cleanup state before
abruptly closing. |
protected ConnectionContext |
delegate()
Get the
ConnectionContext that this class delegates to. |
ExecutionContext |
executionContext()
Get the
ExecutionContext for this ConnectionContext . |
java.net.SocketAddress |
localAddress()
The
SocketAddress to which the associated connection is bound. |
Completable |
onClose()
Returns a
Completable that is notified once the ListenableAsyncCloseable was closed. |
ConnectionContext.Protocol |
protocol()
Get the
ConnectionContext.Protocol for this ConnectionContext . |
java.net.SocketAddress |
remoteAddress()
The
SocketAddress to which the associated connection is connected. |
<T> T |
socketOption(java.net.SocketOption<T> option)
|
javax.net.ssl.SSLSession |
sslSession()
Get the
SSLSession for this connection. |
public DelegatingConnectionContext(ConnectionContext delegate)
delegate
- ConnectionContext
to delegate all calls.protected ConnectionContext delegate()
ConnectionContext
that this class delegates to.ConnectionContext
that this class delegates to.public java.net.SocketAddress localAddress()
ConnectionContext
SocketAddress
to which the associated connection is bound.localAddress
in interface ConnectionContext
SocketAddress
to which the associated connection is bound.public java.net.SocketAddress remoteAddress()
ConnectionContext
SocketAddress
to which the associated connection is connected.remoteAddress
in interface ConnectionContext
SocketAddress
to which the associated connection is connected.@Nullable public javax.net.ssl.SSLSession sslSession()
ConnectionContext
SSLSession
for this connection.sslSession
in interface ConnectionContext
SSLSession
if SSL/TLS is enabled, or null
otherwise.public ExecutionContext executionContext()
ConnectionContext
ExecutionContext
for this ConnectionContext
.
The ExecutionContext.ioExecutor()
will represent the thread responsible for IO for this
ConnectionContext
. Note that this maybe different that what was used to create this object because
at this time a specific IoExecutor
has been selected.
executionContext
in interface ConnectionContext
ExecutionContext
for this ConnectionContext
.public <T> T socketOption(java.net.SocketOption<T> option)
ConnectionContext
socketOption
in interface ConnectionContext
T
- the type of the SocketOption
value.option
- SocketOption
to get.SocketOption
value of type T
for this ConnectionContext
or null
if
this SocketOption
is not supported by this ConnectionContext
.StandardSocketOptions
,
ServiceTalkSocketOptions
public ConnectionContext.Protocol protocol()
ConnectionContext
ConnectionContext.Protocol
for this ConnectionContext
.protocol
in interface ConnectionContext
ConnectionContext.Protocol
for this ConnectionContext
.public Completable onClose()
ListenableAsyncCloseable
Completable
that is notified once the ListenableAsyncCloseable
was closed.onClose
in interface ListenableAsyncCloseable
Completable
that is notified on close.public Completable closeAsync()
AsyncCloseable
closeAsync
in interface AsyncCloseable
CompletableSource
that is notified once the close is complete.public Completable closeAsyncGracefully()
AsyncCloseable
AsyncCloseable.closeAsync()
, but attempts to cleanup state before
abruptly closing. This provides a hint that implementations can use to stop accepting new work and finish in
flight work. This method is implemented on a "best effort" basis and may be equivalent to AsyncCloseable.closeAsync()
.
Note: Implementations may or may not apply a timeout for this operation to complete, if a caller does not
want to wait indefinitely, and are unsure if the implementation applies a timeout, it is advisable to apply a
timeout and force a call to AsyncCloseable.closeAsync()
.
closeAsyncGracefully
in interface AsyncCloseable
Completable
that is notified once the close is complete.