public abstract class WrapperWithContext<T> extends Wrapper<T>
| Modifier | Constructor | Description |
|---|---|---|
protected |
WrapperWithContext(ContextSnapshot snapshot,
T delegate) |
Creates a new Wrapper with the specified context snapshot.
|
protected |
WrapperWithContext(ContextSnapshotSupplier supplier,
T delegate) |
Wraps the delegate and provides a context snapshot.
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
equals(Object other) |
|
int |
hashCode() |
|
protected ContextSnapshot |
snapshot() |
Calls the supplier for the context snapshot, making sure it is called only once for this wrapper instance.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitdelegate, nonNullDelegateprotected WrapperWithContext(ContextSnapshot snapshot, T delegate)
snapshot - The context snapshot (required, non-null)delegate - The wrapped delegate object providing core functionalityprotected WrapperWithContext(ContextSnapshotSupplier supplier, T delegate)
Note: Make sure the supplier function does not obtain the context snapshot
from any threadlocal storage! The wrapper is designed to propagate contexts from one thread to another.
Therefore, the snapshot must be captured
in the source thread and reactivated in the target thread.
If unsure, please use the
constructor with snapshot instead.
supplier - The supplier for the (fixed!) context snapshot.
This can be a straightforward 'holder' object or an ongoing background call.
Please do not make this supplier function access any ThreadLocal value,
as the wrapper is designed to propagate the snapshot from thread to thread!delegate - The delegate object to be wrapped.WrapperWithContext(ContextSnapshot, Object)protected ContextSnapshot snapshot()
Copyright © 2016–2018 Talsma ICT. All rights reserved.