Module org.elasticsearch.server
Package org.elasticsearch.action.support
Class ContextPreservingActionListener<R>
java.lang.Object
org.elasticsearch.action.DelegatingActionListener<R,R>
org.elasticsearch.action.support.ContextPreservingActionListener<R>
- All Implemented Interfaces:
ActionListener<R>
Restores the given
ThreadContext.StoredContext
once the listener is invoked-
Field Summary
Fields inherited from class org.elasticsearch.action.DelegatingActionListener
delegate -
Constructor Summary
ConstructorsConstructorDescriptionContextPreservingActionListener(Supplier<ThreadContext.StoredContext> contextSupplier, ActionListener<R> delegate) -
Method Summary
Modifier and TypeMethodDescriptionvoidComplete this listener with an exceptional response.voidonResponse(R r) Complete this listener with a successful (or at least, non-exceptional) 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 closedMethods inherited from class org.elasticsearch.action.DelegatingActionListener
toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.action.ActionListener
delegateFailure, delegateFailureAndWrap, delegateFailureIgnoreResponseAndWrap, delegateResponse, map, safeMap
-
Constructor Details
-
ContextPreservingActionListener
public ContextPreservingActionListener(Supplier<ThreadContext.StoredContext> contextSupplier, ActionListener<R> delegate)
-
-
Method Details
-
onResponse
Description copied from interface:ActionListenerComplete this listener with a successful (or at least, non-exceptional) response. -
onFailure
Description copied from interface:ActionListenerComplete this listener with an exceptional response.- Specified by:
onFailurein interfaceActionListener<R>- Overrides:
onFailurein classDelegatingActionListener<R,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
-