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.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. |
java.net.SocketAddress |
remoteAddress()
The
SocketAddress to which the associated connection is connected. |
javax.net.ssl.SSLSession |
sslSession()
Get the
SSLSession for this connection. |
public DelegatingConnectionContext(ConnectionContext delegate)
delegate
- ConnectionContext
to delegate all calls.protected final 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 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.