Package io.grpc
Class Context.Storage
- java.lang.Object
-
- io.grpc.Context.Storage
-
- Enclosing class:
- Context
public abstract static class Context.Storage extends Object
Defines the mechanisms for attaching and detaching the "current" context. The constructor for extending classes must not trigger any activity that can use Context, which includes logging, otherwise it can trigger an infinite initialization loop. Extending classes must not assume that only one instance will be created; Context guarantees it will only use one instance, but it may create multiple and then throw away all but one.The default implementation will put the current context in a
ThreadLocal. If an alternative implementation namedio.grpc.override.ContextStorageOverrideexists in the classpath, it will be used instead of the default implementation.This API is experimental and subject to change.
-
-
Constructor Summary
Constructors Constructor Description Storage()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract Contextcurrent()ImplementsContext.current().abstract voiddetach(Context toDetach, Context toRestore)ImplementsContext.detach(io.grpc.Context).abstract ContextdoAttach(Context toAttach)ImplementsContext.attach().
-
-
-
Method Detail
-
doAttach
public abstract Context doAttach(Context toAttach)
ImplementsContext.attach().Caution:
Context.attach()interprets a return value ofnullto mean the same thing asContext.ROOT.See also:
current().- Parameters:
toAttach- the context to be attached- Returns:
- A
Contextthat should be passed back intodetach(Context, Context)as thetoRestoreparameter.nullis a valid return value, but see caution note.
-
detach
public abstract void detach(Context toDetach, Context toRestore)
ImplementsContext.detach(io.grpc.Context).- Parameters:
toDetach- the context to be detached. Should be, or be equivalent to, the current context of the current scopetoRestore- the context to be the current. Should be, or be equivalent to, the context of the outer scope
-
current
public abstract Context current()
ImplementsContext.current().Caution:
Contextinterprets a return value ofnullto mean the same thing asContext.ROOT.See also
doAttach(Context).- Returns:
- The context of the current scope.
nullis a valid return value, but see caution note.
-
-