Package org.elasticsearch.action.support
Class ContextPreservingActionListener<R>
- java.lang.Object
-
- org.elasticsearch.action.support.ContextPreservingActionListener<R>
-
- All Implemented Interfaces:
ActionListener<R>
public final class ContextPreservingActionListener<R> extends java.lang.Object implements ActionListener<R>
Restores the givenThreadContext.StoredContextonce the listener is invoked
-
-
Constructor Summary
Constructors Constructor Description ContextPreservingActionListener(java.util.function.Supplier<ThreadContext.StoredContext> contextSupplier, ActionListener<R> delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidonFailure(java.lang.Exception e)A failure caused by an exception at some phase of the task.voidonResponse(R r)Handle action response.static <R> ContextPreservingActionListener<R>wrapPreservingContext(ActionListener<R> listener, ThreadContext threadContext)Wraps the provided action listener in aContextPreservingActionListenerthat will also copy the response headers when theThreadContext.StoredContextis closed
-
-
-
Constructor Detail
-
ContextPreservingActionListener
public ContextPreservingActionListener(java.util.function.Supplier<ThreadContext.StoredContext> contextSupplier, ActionListener<R> delegate)
-
-
Method Detail
-
onResponse
public void onResponse(R r)
Description copied from interface:ActionListenerHandle action response. This response may constitute a failure or a success but it is up to the listener to make that decision.- Specified by:
onResponsein interfaceActionListener<R>
-
onFailure
public void onFailure(java.lang.Exception e)
Description copied from interface:ActionListenerA failure caused by an exception at some phase of the task.- Specified by:
onFailurein interfaceActionListener<R>
-
wrapPreservingContext
public static <R> ContextPreservingActionListener<R> wrapPreservingContext(ActionListener<R> listener, ThreadContext threadContext)
Wraps the provided action listener in aContextPreservingActionListenerthat will also copy the response headers when theThreadContext.StoredContextis closed
-
-