Class A2AExtensionsInterceptor
- All Implemented Interfaces:
io.grpc.ServerInterceptor
grpc.aio.ServicerContext.
This interceptor executes before service methods are invoked, extracting A2A protocol
headers and request metadata from the gRPC call and storing them in the gRPC Context
for access by GrpcHandler and agent implementations.
Captured Information
- A2A Protocol Version:
a2a-versionheader - A2A Extensions:
a2a-extensionsheader - Complete Metadata: All request headers via
Metadata - Method Name: gRPC method being invoked
- Peer Information: Client connection details
Context Storage
All captured information is stored in the gRPC Context using keys from
GrpcContextKeys:
VERSION_HEADER_KEYEXTENSIONS_HEADER_KEYMETADATA_KEYGRPC_METHOD_NAME_KEYMETHOD_NAME_KEYPEER_INFO_KEY
CDI Integration
This interceptor is registered as an @ApplicationScoped CDI bean and automatically
applied to gRPC services through Quarkus gRPC's @RegisterInterceptor annotation.
Python Equivalence
This interceptor provides functionality equivalent to Python's grpc.aio.ServicerContext,
enabling Java handlers to access the same rich context information available in Python implementations:
context.invocation_metadata()→Metadatacontext.method()→ Method name viaGRPC_METHOD_NAME_KEYcontext.peer()→ Peer info viaPEER_INFO_KEY
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<ReqT,RespT>
io.grpc.ServerCall.Listener<ReqT> interceptCall(io.grpc.ServerCall<ReqT, RespT> serverCall, io.grpc.Metadata metadata, io.grpc.ServerCallHandler<ReqT, RespT> serverCallHandler) Intercepts incoming gRPC calls to capture metadata and context information.
-
Constructor Details
-
A2AExtensionsInterceptor
public A2AExtensionsInterceptor()
-
-
Method Details
-
interceptCall
public <ReqT,RespT> io.grpc.ServerCall.Listener<ReqT> interceptCall(io.grpc.ServerCall<ReqT, RespT> serverCall, io.grpc.Metadata metadata, io.grpc.ServerCallHandler<ReqT, RespT> serverCallHandler) Intercepts incoming gRPC calls to capture metadata and context information.This method extracts A2A protocol headers and request metadata, stores them in the gRPC
Context, and proceeds with the call in the enhanced context.Extraction Process:
- Extract
a2a-versionheader from metadata - Extract
a2a-extensionsheader from metadata - Capture complete
Metadataobject - Capture gRPC method name from
ServerCall - Map gRPC method to A2A protocol method name
- Extract peer information from server call attributes
- Create enhanced
Contextwith all captured information - Proceed with call in enhanced context
- Specified by:
interceptCallin interfaceio.grpc.ServerInterceptor- Type Parameters:
ReqT- the request message typeRespT- the response message type- Parameters:
serverCall- the gRPC server callmetadata- the request metadata (headers)serverCallHandler- the next handler in the interceptor chain- Returns:
- a listener for the server call
- Extract
-