Class ContextSnapshotFactoryHelper
java.lang.Object
org.springframework.graphql.execution.ContextSnapshotFactoryHelper
Helper to use a single
ContextSnapshotFactory
instance by saving and
obtaining it to and from Reactor and GraphQL contexts.- Since:
- 1.3.0
- Author:
- Rossen Stoyanchev
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic io.micrometer.context.ContextSnapshot
captureFrom
(GraphQLContext context) Shortcut to obtain theContextSnapshotFactory
instance, and to capture from the givenGraphQLContext
.static io.micrometer.context.ContextSnapshot
captureFrom
(reactor.util.context.ContextView contextView) Shortcut to obtain theContextSnapshotFactory
instance, and to capture from the givenContextView
.static io.micrometer.context.ContextSnapshotFactory
getInstance
(GraphQLContext context) Access theContextSnapshotFactory
from the givenGraphQLContext
or return a shared, static instance.static io.micrometer.context.ContextSnapshotFactory
getInstance
(reactor.util.context.ContextView contextView) Access theContextSnapshotFactory
from the givenContextView
or return a shared, static instance.static void
saveInstance
(io.micrometer.context.ContextSnapshotFactory factory, GraphQLContext context) Save theContextSnapshotFactory
in the givenContext
.static reactor.util.context.Context
saveInstance
(io.micrometer.context.ContextSnapshotFactory factory, reactor.util.context.Context context) Save theContextSnapshotFactory
in the givenContext
.static io.micrometer.context.ContextSnapshotFactory
selectInstance
(io.micrometer.context.ContextSnapshotFactory factory) Select aContextSnapshotFactory
instance to use, either the one passed in if it is notnull
, or a shared, static instance.
-
Constructor Details
-
ContextSnapshotFactoryHelper
public ContextSnapshotFactoryHelper()
-
-
Method Details
-
selectInstance
public static io.micrometer.context.ContextSnapshotFactory selectInstance(@Nullable io.micrometer.context.ContextSnapshotFactory factory) Select aContextSnapshotFactory
instance to use, either the one passed in if it is notnull
, or a shared, static instance.- Parameters:
factory
- the candidate factory instance to use if notnull
- Returns:
- the instance to use
-
saveInstance
public static reactor.util.context.Context saveInstance(io.micrometer.context.ContextSnapshotFactory factory, reactor.util.context.Context context) Save theContextSnapshotFactory
in the givenContext
.- Parameters:
factory
- the instance to savecontext
- the context to save the instance to- Returns:
- a new context with the saved instance
-
saveInstance
public static void saveInstance(io.micrometer.context.ContextSnapshotFactory factory, GraphQLContext context) Save theContextSnapshotFactory
in the givenContext
.- Parameters:
factory
- the instance to savecontext
- the context to save the instance to
-
getInstance
public static io.micrometer.context.ContextSnapshotFactory getInstance(reactor.util.context.ContextView contextView) Access theContextSnapshotFactory
from the givenContextView
or return a shared, static instance.- Parameters:
contextView
- the context where the instance is saved- Returns:
- the instance to use
-
getInstance
Access theContextSnapshotFactory
from the givenGraphQLContext
or return a shared, static instance.- Parameters:
context
- the context where the instance is saved- Returns:
- the instance to use
-
captureFrom
public static io.micrometer.context.ContextSnapshot captureFrom(reactor.util.context.ContextView contextView) Shortcut to obtain theContextSnapshotFactory
instance, and to capture from the givenContextView
.- Parameters:
contextView
- the context to capture from- Returns:
- a snapshot from the capture
-
captureFrom
Shortcut to obtain theContextSnapshotFactory
instance, and to capture from the givenGraphQLContext
.- Parameters:
context
- the context to capture from- Returns:
- a snapshot from the capture
-