Package io.servicetalk.http.api
Class DelegatingHttpServiceContext
- java.lang.Object
-
- io.servicetalk.http.api.HttpServiceContext
-
- io.servicetalk.http.api.DelegatingHttpServiceContext
-
- All Implemented Interfaces:
AsyncCloseable
,ListenableAsyncCloseable
,HttpConnectionContext
,ConnectionContext
,ConnectionInfo
public class DelegatingHttpServiceContext extends HttpServiceContext
An implementation ofHttpServiceContext
that delegates all calls to a providedHttpServiceContext
. Any method can be overridden to change this default behavior.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.servicetalk.transport.api.ConnectionInfo
ConnectionInfo.Protocol
-
-
Constructor Summary
Constructors Constructor Description DelegatingHttpServiceContext(HttpServiceContext other)
New instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Completable
closeAsync()
Used to close/shutdown a resource.Completable
closeAsyncGracefully()
Used to close/shutdown a resource, similar toAsyncCloseable.closeAsync()
, but attempts to cleanup state before abruptly closing.HttpExecutionContext
executionContext()
Get theExecutionContext
for thisConnectionInfo
.java.net.SocketAddress
localAddress()
TheSocketAddress
to which the associated connection is bound.Completable
onClose()
Returns aCompletable
that is notified once theListenableAsyncCloseable
was closed.HttpProtocolVersion
protocol()
Get theConnectionInfo.Protocol
for thisConnectionInfo
.java.net.SocketAddress
remoteAddress()
TheSocketAddress
to which the associated connection is connected.<T> T
socketOption(java.net.SocketOption<T> option)
javax.net.ssl.SSLSession
sslSession()
Get theSSLSession
for this connection.-
Methods inherited from class io.servicetalk.http.api.HttpServiceContext
blockingStreamingResponseFactory, headersFactory, responseFactory, streamingResponseFactory
-
-
-
-
Constructor Detail
-
DelegatingHttpServiceContext
public DelegatingHttpServiceContext(HttpServiceContext other)
New instance.- Parameters:
other
-HttpServiceContext
to delegate all calls.
-
-
Method Detail
-
localAddress
public java.net.SocketAddress localAddress()
Description copied from interface:ConnectionInfo
TheSocketAddress
to which the associated connection is bound.- Returns:
- The
SocketAddress
to which the associated connection is bound.
-
remoteAddress
public java.net.SocketAddress remoteAddress()
Description copied from interface:ConnectionInfo
TheSocketAddress
to which the associated connection is connected.- Returns:
- The
SocketAddress
to which the associated connection is connected.
-
sslSession
@Nullable public javax.net.ssl.SSLSession sslSession()
Description copied from interface:ConnectionInfo
Get theSSLSession
for this connection.- Returns:
- The
SSLSession
if SSL/TLS is enabled, ornull
otherwise.
-
executionContext
public HttpExecutionContext executionContext()
Description copied from interface:ConnectionInfo
Get theExecutionContext
for 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 specificIoExecutor
has been selected.- Returns:
- the
ExecutionContext
for thisConnectionInfo
.
-
socketOption
@Nullable public <T> T socketOption(java.net.SocketOption<T> option)
Description copied from interface:ConnectionInfo
- Type Parameters:
T
- the type of theSocketOption
value.- Parameters:
option
-SocketOption
to get.- Returns:
- the
SocketOption
value of typeT
for thisConnectionInfo
ornull
if thisSocketOption
is not supported by thisConnectionInfo
. - See Also:
StandardSocketOptions
,ServiceTalkSocketOptions
-
protocol
public HttpProtocolVersion protocol()
Description copied from interface:ConnectionInfo
Get theConnectionInfo.Protocol
for thisConnectionInfo
.- Returns:
- the
ConnectionInfo.Protocol
for thisConnectionInfo
.
-
onClose
public Completable onClose()
Description copied from interface:ListenableAsyncCloseable
Returns aCompletable
that is notified once theListenableAsyncCloseable
was closed.- Returns:
- the
Completable
that is notified on close.
-
closeAsync
public Completable closeAsync()
Description copied from interface:AsyncCloseable
Used to close/shutdown a resource.- Returns:
- A
Completable
that is notified once the close is complete.
-
closeAsyncGracefully
public Completable closeAsyncGracefully()
Description copied from interface:AsyncCloseable
Used 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()
.- Returns:
- A
Completable
that is notified once the close is complete.
-
-