Package io.servicetalk.transport.api
Class DelegatingConnectionContext
- java.lang.Object
-
- io.servicetalk.transport.api.DelegatingConnectionContext
-
- All Implemented Interfaces:
AsyncCloseable,ListenableAsyncCloseable,ConnectionContext,ConnectionInfo
- Direct Known Subclasses:
DelegatingHttpConnectionContext
public class DelegatingConnectionContext extends java.lang.Object implements ConnectionContext
AConnectionContextimplementation that delegates all calls to a providedConnectionContext. Any of the methods can be overridden by implementations to change the behavior.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.servicetalk.transport.api.ConnectionInfo
ConnectionInfo.Protocol
-
-
Constructor Summary
Constructors Constructor Description DelegatingConnectionContext(ConnectionContext delegate)New instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletablecloseAsync()Used to close/shutdown a resource.CompletablecloseAsyncGracefully()Used to close/shutdown a resource, similar toAsyncCloseable.closeAsync(), but attempts to cleanup state before abruptly closing.protected ConnectionContextdelegate()Get theConnectionContextthat this class delegates to.ExecutionContextexecutionContext()Get theExecutionContextfor thisConnectionInfo.java.net.SocketAddresslocalAddress()TheSocketAddressto which the associated connection is bound.CompletableonClose()Returns aCompletablethat is notified once theListenableAsyncCloseablewas closed.ConnectionInfo.Protocolprotocol()Get theConnectionInfo.Protocolfor thisConnectionInfo.java.net.SocketAddressremoteAddress()TheSocketAddressto which the associated connection is connected.<T> TsocketOption(java.net.SocketOption<T> option)javax.net.ssl.SSLSessionsslSession()Get theSSLSessionfor this connection.java.lang.StringtoString()
-
-
-
Constructor Detail
-
DelegatingConnectionContext
public DelegatingConnectionContext(ConnectionContext delegate)
New instance.- Parameters:
delegate-ConnectionContextto delegate all calls.
-
-
Method Detail
-
delegate
protected ConnectionContext delegate()
Get theConnectionContextthat this class delegates to.- Returns:
- the
ConnectionContextthat this class delegates to.
-
localAddress
public java.net.SocketAddress localAddress()
Description copied from interface:ConnectionInfoTheSocketAddressto which the associated connection is bound.- Specified by:
localAddressin interfaceConnectionInfo- Returns:
- The
SocketAddressto which the associated connection is bound.
-
remoteAddress
public java.net.SocketAddress remoteAddress()
Description copied from interface:ConnectionInfoTheSocketAddressto which the associated connection is connected.- Specified by:
remoteAddressin interfaceConnectionInfo- Returns:
- The
SocketAddressto which the associated connection is connected.
-
sslSession
@Nullable public javax.net.ssl.SSLSession sslSession()
Description copied from interface:ConnectionInfoGet theSSLSessionfor this connection.- Specified by:
sslSessionin interfaceConnectionInfo- Returns:
- The
SSLSessionif SSL/TLS is enabled, ornullotherwise.
-
executionContext
public ExecutionContext executionContext()
Description copied from interface:ConnectionInfoGet theExecutionContextfor thisConnectionInfo.The
ExecutionContext.ioExecutor()will represent the thread responsible for IO for thisConnectionInfo. Note that this maybe different that what was used to create this object because at this time a specificIoExecutorhas been selected.- Specified by:
executionContextin interfaceConnectionInfo- Returns:
- the
ExecutionContextfor thisConnectionInfo.
-
socketOption
public <T> T socketOption(java.net.SocketOption<T> option)
Description copied from interface:ConnectionInfo- Specified by:
socketOptionin interfaceConnectionInfo- Type Parameters:
T- the type of theSocketOptionvalue.- Parameters:
option-SocketOptionto get.- Returns:
- the
SocketOptionvalue of typeTfor thisConnectionInfoornullif thisSocketOptionis not supported by thisConnectionInfo. - See Also:
StandardSocketOptions,ServiceTalkSocketOptions
-
protocol
public ConnectionInfo.Protocol protocol()
Description copied from interface:ConnectionInfoGet theConnectionInfo.Protocolfor thisConnectionInfo.- Specified by:
protocolin interfaceConnectionInfo- Returns:
- the
ConnectionInfo.Protocolfor thisConnectionInfo.
-
onClose
public Completable onClose()
Description copied from interface:ListenableAsyncCloseableReturns aCompletablethat is notified once theListenableAsyncCloseablewas closed.- Specified by:
onClosein interfaceListenableAsyncCloseable- Returns:
- the
Completablethat is notified on close.
-
closeAsync
public Completable closeAsync()
Description copied from interface:AsyncCloseableUsed to close/shutdown a resource.- Specified by:
closeAsyncin interfaceAsyncCloseable- Returns:
- A
Completablethat is notified once the close is complete.
-
closeAsyncGracefully
public Completable closeAsyncGracefully()
Description copied from interface:AsyncCloseableUsed to close/shutdown a resource, similar toAsyncCloseable.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 toAsyncCloseable.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().- Specified by:
closeAsyncGracefullyin interfaceAsyncCloseable- Returns:
- A
Completablethat is notified once the close is complete.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-