public class DelegatingHttpExecutionStrategy extends java.lang.Object implements HttpExecutionStrategy
HttpExecutionStrategy
that delegates all method calls to another HttpExecutionStrategy
.Constructor and Description |
---|
DelegatingHttpExecutionStrategy(HttpExecutionStrategy delegate)
Create a new instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
Executor |
executor()
Returns the
Executor , if any for this ExecutionStrategy . |
int |
hashCode() |
<FS> Single<StreamingHttpResponse> |
invokeClient(Executor fallback,
Publisher<java.lang.Object> flattenedRequest,
FS flushStrategy,
ClientInvoker<FS> client)
Invokes the passed
Function and applies the necessary offloading of request and response for a client. |
<T> Single<T> |
invokeService(Executor fallback,
java.util.function.Function<Executor,T> service)
Invokes a service represented by the passed
Function . |
Publisher<java.lang.Object> |
invokeService(Executor fallback,
StreamingHttpRequest request,
java.util.function.Function<StreamingHttpRequest,Publisher<java.lang.Object>> service,
java.util.function.BiFunction<java.lang.Throwable,Executor,Publisher<java.lang.Object>> errorHandler)
Invokes the passed
Function and applies the necessary offloading of request and response for a server. |
boolean |
isDataReceiveOffloaded()
Returns
true if data receive offloading is enabled for this ExecutionStrategy . |
boolean |
isMetadataReceiveOffloaded()
Returns
true if metadata receive offloading is enabled for this ExecutionStrategy . |
boolean |
isSendOffloaded()
Returns
true if send offloading is enabled for this ExecutionStrategy . |
HttpExecutionStrategy |
merge(HttpExecutionStrategy other)
Merges the passed
HttpExecutionStrategy with this HttpExecutionStrategy and return the
merged result. |
<T> Publisher<T> |
offloadReceive(Executor fallback,
Publisher<T> original)
Offloads the
original Publisher for receiving data from the transport. |
<T> Single<T> |
offloadReceive(Executor fallback,
Single<T> original)
Offloads the
original Single for receiving data from the transport. |
<T> Publisher<T> |
offloadSend(Executor fallback,
Publisher<T> original)
Offloads the
original Publisher for sending data on the transport. |
<T> Single<T> |
offloadSend(Executor fallback,
Single<T> original)
Offloads the
original Single for sending data on the transport. |
StreamingHttpService |
offloadService(Executor fallback,
StreamingHttpService handler)
Wraps the passed
StreamingHttpService to apply this HttpExecutionStrategy . |
public DelegatingHttpExecutionStrategy(HttpExecutionStrategy delegate)
delegate
- HttpExecutionStrategy
to which all method calls will be delegated.public <FS> Single<StreamingHttpResponse> invokeClient(Executor fallback, Publisher<java.lang.Object> flattenedRequest, FS flushStrategy, ClientInvoker<FS> client)
HttpExecutionStrategy
Function
and applies the necessary offloading of request and response for a client.invokeClient
in interface HttpExecutionStrategy
FS
- The FlushStrategy
type to use.fallback
- Executor
to use as a fallback if this HttpExecutionStrategy
does not define an
Executor
.flattenedRequest
- A flattened Publisher
containing all data constituting an HTTP request.flushStrategy
- The FlushStrategy
to use.client
- A BiFunction
that given flattened stream of HttpRequestMetaData
, payload and
trailers, for the passed StreamingHttpRequest
returns a Single
.Single
which is offloaded as required.public Publisher<java.lang.Object> invokeService(Executor fallback, StreamingHttpRequest request, java.util.function.Function<StreamingHttpRequest,Publisher<java.lang.Object>> service, java.util.function.BiFunction<java.lang.Throwable,Executor,Publisher<java.lang.Object>> errorHandler)
HttpExecutionStrategy
Function
and applies the necessary offloading of request and response for a server.invokeService
in interface HttpExecutionStrategy
fallback
- Executor
to use as a fallback if this HttpExecutionStrategy
does not define an
Executor
.request
- StreamingHttpRequest
for which the offloading is to be applied.service
- A Function
that executes a StreamingHttpRequest
and returns a flattened
Publisher
containing all data constituting an HTTP response.errorHandler
- In case there is an error before calling the passed service
, this BiFunction
will be called to generate an error response.Publisher
containing all data constituting an HTTP response..public <T> Single<T> invokeService(Executor fallback, java.util.function.Function<Executor,T> service)
HttpExecutionStrategy
Function
.
This method does not apply the strategy on the object returned from the Function
, if that object is an
asynchronous source then the caller of this method should take care and offload that source using
ExecutionStrategy.offloadSend(Executor, Single)
or ExecutionStrategy.offloadSend(Executor, Publisher)
.
invokeService
in interface HttpExecutionStrategy
T
- Type of result of the invocation of the service.fallback
- Executor
to use as a fallback if this HttpExecutionStrategy
does not define an
Executor
.service
- Function
representing a service.Single
that invokes the passed Function
and returns the result asynchronously.
Invocation of Function
will be offloaded if configured.public StreamingHttpService offloadService(Executor fallback, StreamingHttpService handler)
HttpExecutionStrategy
StreamingHttpService
to apply this HttpExecutionStrategy
.offloadService
in interface HttpExecutionStrategy
fallback
- Executor
to use as a fallback if this HttpExecutionStrategy
does not define an
Executor
.handler
- StreamingHttpService
to wrap.StreamingHttpService
.public boolean isMetadataReceiveOffloaded()
HttpExecutionStrategy
true
if metadata receive offloading is enabled for this ExecutionStrategy
.isMetadataReceiveOffloaded
in interface HttpExecutionStrategy
true
if metadata receive offloading is enabled for this ExecutionStrategy
.public boolean isDataReceiveOffloaded()
HttpExecutionStrategy
true
if data receive offloading is enabled for this ExecutionStrategy
.isDataReceiveOffloaded
in interface HttpExecutionStrategy
true
if data receive offloading is enabled for this ExecutionStrategy
.public boolean isSendOffloaded()
HttpExecutionStrategy
true
if send offloading is enabled for this ExecutionStrategy
.isSendOffloaded
in interface HttpExecutionStrategy
true
if send offloading is enabled for this ExecutionStrategy
.public HttpExecutionStrategy merge(HttpExecutionStrategy other)
HttpExecutionStrategy
HttpExecutionStrategy
with this
HttpExecutionStrategy
and return the
merged result.merge
in interface HttpExecutionStrategy
other
- HttpExecutionStrategy
to merge with this
.HttpExecutionStrategy
.public <T> Single<T> offloadSend(Executor fallback, Single<T> original)
ExecutionStrategy
original
Single
for sending data on the transport.offloadSend
in interface ExecutionStrategy
T
- Type of result of the original
Single
.fallback
- Executor
to use as a fallback if this ExecutionStrategy
does not define an
Executor
.original
- Single
to offload.Single
.public <T> Single<T> offloadReceive(Executor fallback, Single<T> original)
ExecutionStrategy
original
Single
for receiving data from the transport.offloadReceive
in interface ExecutionStrategy
T
- Type of result of the original
Single
.fallback
- Executor
to use as a fallback if this ExecutionStrategy
does not define an
Executor
.original
- Single
to offload.Single
.public <T> Publisher<T> offloadSend(Executor fallback, Publisher<T> original)
ExecutionStrategy
original
Publisher
for sending data on the transport.offloadSend
in interface ExecutionStrategy
T
- Type of items emitted from the original
Publisher
.fallback
- Executor
to use as a fallback if this ExecutionStrategy
does not define an
Executor
.original
- Publisher
to offload.Publisher
.public <T> Publisher<T> offloadReceive(Executor fallback, Publisher<T> original)
ExecutionStrategy
original
Publisher
for receiving data from the transport.offloadReceive
in interface ExecutionStrategy
T
- Type of items emitted from the original
Publisher
.fallback
- Executor
to use as a fallback if this ExecutionStrategy
does not define an
Executor
.original
- Publisher
to offload.Publisher
.@Nullable public Executor executor()
ExecutionStrategy
Executor
, if any for this ExecutionStrategy
.executor
in interface ExecutionStrategy
Executor
for this ExecutionStrategy
. null
if none specified.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object