MCPcopy Create free account
hub / github.com/grpc/grpc-java / interceptCall

Method interceptCall

api/src/main/java/io/grpc/Contexts.java:44–57  ·  view source on GitHub ↗

Make the provided Context Context#current() for the creation of a listener to a received call and for all events received by that listener. This utility is expected to be used by ServerInterceptor implementations that need to augment the Context in which the appli

(
        Context context,
        ServerCall<ReqT, RespT> call,
        Metadata headers,
        ServerCallHandler<ReqT, RespT> next)

Source from the content-addressed store, hash-verified

42 * @return listener that will receive events in the scope of the provided context.
43 */
44 public static <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
45 Context context,
46 ServerCall<ReqT, RespT> call,
47 Metadata headers,
48 ServerCallHandler<ReqT, RespT> next) {
49 Context previous = context.attach();
50 try {
51 return new ContextualizedServerCallListener<>(
52 next.startCall(call, headers),
53 context);
54 } finally {
55 context.detach(previous);
56 }
57 }
58
59 /**
60 * Implementation of {@link io.grpc.ForwardingServerCallListener} that attaches a context before

Callers 6

interceptCallMethod · 0.95
interceptCallMethod · 0.95
interceptCallMethod · 0.95
interceptCallMethod · 0.95
interceptCallMethod · 0.95
interceptCallMethod · 0.95

Calls 3

startCallMethod · 0.65
detachMethod · 0.65
attachMethod · 0.45

Tested by 2

interceptCallMethod · 0.76
interceptCallMethod · 0.76