Package org.elasticsearch.action.support
Class ContextPreservingActionListener<R>
java.lang.Object
org.elasticsearch.action.ActionListener.Delegating<R,R>
org.elasticsearch.action.support.ContextPreservingActionListener<R>
- All Implemented Interfaces:
ActionListener<R>
Restores the given
ThreadContext.StoredContext
once the listener is invoked-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.action.ActionListener
ActionListener.Delegating<Response,DelegateResponse>, ActionListener.DelegatingActionListener<T>, ActionListener.DelegatingFailureActionListener<T,R>, ActionListener.MappedActionListener<Response,MappedResponse>, ActionListener.RunAfterActionListener<T>, ActionListener.RunBeforeActionListener<T>
-
Field Summary
Fields inherited from class org.elasticsearch.action.ActionListener.Delegating
delegate
-
Constructor Summary
ConstructorDescriptionContextPreservingActionListener(Supplier<ThreadContext.StoredContext> contextSupplier, ActionListener<R> delegate)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
A failure caused by an exception at some phase of the task.void
onResponse(R r)
Handle action response.static <R> ContextPreservingActionListener<R>
wrapPreservingContext(ActionListener<R> listener, ThreadContext threadContext)
Wraps the provided action listener in aContextPreservingActionListener
that will also copy the response headers when theThreadContext.StoredContext
is closedMethods inherited from class org.elasticsearch.action.ActionListener.Delegating
toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.action.ActionListener
delegateFailure, delegateResponse, map
-
Constructor Details
-
ContextPreservingActionListener
public ContextPreservingActionListener(Supplier<ThreadContext.StoredContext> contextSupplier, ActionListener<R> delegate)
-
-
Method Details
-
onResponse
Description copied from interface:ActionListener
Handle action response. This response may constitute a failure or a success but it is up to the listener to make that decision. -
onFailure
Description copied from interface:ActionListener
A failure caused by an exception at some phase of the task.- Specified by:
onFailure
in interfaceActionListener<R>
- Overrides:
onFailure
in classActionListener.Delegating<R,R>
-
wrapPreservingContext
public static <R> ContextPreservingActionListener<R> wrapPreservingContext(ActionListener<R> listener, ThreadContext threadContext)Wraps the provided action listener in aContextPreservingActionListener
that will also copy the response headers when theThreadContext.StoredContext
is closed
-