Class Context<T>
- java.lang.Object
-
- com.lightbend.cinnamon.propagation.Context<T>
-
public abstract class Context<T> extends java.lang.Object
Context SPI for automatic context propagation.
-
-
Constructor Summary
Constructors Constructor Description Context()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description T
cast(java.lang.Object context)
Cast an untyped object to the context type.abstract T
get()
Get the current context object for propagation.T
join(T firstContext, T secondContext)
Join two propagated context objects (such as for Futures).abstract void
set(T context)
Set the propagated context object into the current scope.
-
-
-
Method Detail
-
get
public abstract T get()
Get the current context object for propagation.Note: implementations can return
null
to propagate empty context.- Returns:
- current context object
-
set
public abstract void set(T context)
Set the propagated context object into the current scope.Note: implementations should handle
null
as empty context.- Parameters:
context
- propagated context object, from associatedget()
-
join
public T join(T firstContext, T secondContext)
Join two propagated context objects (such as for Futures).Default implementation prefers the second context (for Futures, the completing context). Override this method to actually join the contexts. Note: implementations should handle
null
as empty context.
-
cast
public T cast(java.lang.Object context)
Cast an untyped object to the context type.- Parameters:
context
- context object- Returns:
- context object as context type
-
-