Package org.forgerock.http.protocol
Class MdcAwareSubscriber<T>
java.lang.Object
org.forgerock.http.protocol.MdcAwareSubscriber<T>
- Type Parameters:
T
- the type of element signaled.
- All Implemented Interfaces:
org.reactivestreams.Subscriber<T>
public final class MdcAwareSubscriber<T>
extends Object
implements org.reactivestreams.Subscriber<T>
An implementation of
Subscriber
that will preserve the SLF4J MDC
.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> org.reactivestreams.Subscriber<T>
mdcAwareSubscriber
(Map<String, String> mdc, org.reactivestreams.Subscriber<T> delegate) Wraps the delegateSubscriber
with anotherSubscriber
instance that will use the providedMDC
context when delegating the calls to the delegatedSubscriber
.static <T> org.reactivestreams.Subscriber<T>
mdcAwareSubscriber
(org.reactivestreams.Subscriber<T> delegate) Wraps the delegateSubscriber
with anotherSubscriber
instance that will capture the currentMDC
context, and will use it when delegating the calls to the delegatedSubscriber
.void
void
void
void
onSubscribe
(org.reactivestreams.Subscription s)
-
Method Details
-
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription s) - Specified by:
onSubscribe
in interfaceorg.reactivestreams.Subscriber<T>
-
onNext
- Specified by:
onNext
in interfaceorg.reactivestreams.Subscriber<T>
-
onError
- Specified by:
onError
in interfaceorg.reactivestreams.Subscriber<T>
-
onComplete
public void onComplete()- Specified by:
onComplete
in interfaceorg.reactivestreams.Subscriber<T>
-
mdcAwareSubscriber
public static <T> org.reactivestreams.Subscriber<T> mdcAwareSubscriber(org.reactivestreams.Subscriber<T> delegate) Wraps the delegateSubscriber
with anotherSubscriber
instance that will capture the currentMDC
context, and will use it when delegating the calls to the delegatedSubscriber
.- Type Parameters:
T
- the type of element signaled.- Parameters:
delegate
- the Subscriber to delegate the calls to- Returns:
- A
Subscriber
that will position the capturedMDC
context before each call. - See Also:
-
mdcAwareSubscriber
public static <T> org.reactivestreams.Subscriber<T> mdcAwareSubscriber(Map<String, String> mdc, org.reactivestreams.Subscriber<T> delegate) Wraps the delegateSubscriber
with anotherSubscriber
instance that will use the providedMDC
context when delegating the calls to the delegatedSubscriber
.- Type Parameters:
T
- the type of element signaled.- Parameters:
mdc
- TheMDC
to use when delegating the callsdelegate
- the Subscriber to delegate the calls to- Returns:
- A
Subscriber
that will position the capturedMDC
context before each call.
-