Interface AsyncInvocationInterceptor
public interface AsyncInvocationInterceptor
Implementations of this interface can intercept asynchronous method invocations. The MP Rest Client implementation
runtime will obtain instances of this interface by invoking the
newInterceptor
method of all registered
AsyncInvocationInterceptorFactory
providers.
The MP Rest Client implementation runtime will invoke the pre
method on the main thread prior to
returning execution back to the calling method of the client interface. The runtime will invoke the
prepareContext
method on the invocation thread before the client request is sent. The
prepareContext
method should always be invoked before the applyContext
method is invoked,
but due to the nature of multithreading, it is possible that applyContext
method may be invoked before
the prepareContext
method has completed. Care should be taken when implementing this interface to avoid
race conditions and deadlocks.
Note that the order in which instances of the AsyncInvocationInterceptor
are invoked are determined by
the priority of the AsyncInvocationInterceptorFactory
provider.
Note that the main and secondary threads handling the request/response may be the same. It depends on how the
implementation chooses to implement the asynchronous handling.- Since:
- 1.1
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This method will be invoked by the MP Rest Client runtime on the "async" thread (i.e.void
This method will be invoked by the MP Rest Client runtime on the "main" thread (i.e.void
This method will be invoked by the MP Rest Client runtime on the "async" thread (i.e.
-
Method Details
-
prepareContext
void prepareContext()This method will be invoked by the MP Rest Client runtime on the "main" thread (i.e. the thread calling the async Rest Client interface method) prior to returning control to the calling method. -
applyContext
void applyContext()This method will be invoked by the MP Rest Client runtime on the "async" thread (i.e. the thread used to actually invoke the remote service and wait for the response) prior to sending the request. -
removeContext
void removeContext()This method will be invoked by the MP Rest Client runtime on the "async" thread (i.e. the thread used to actually invoke the remote service and wait for the response) after all providers on the inbound response flow have been invoked.- Since:
- 1.2
-