Interface CallContextFactory
public interface CallContextFactory
Factory interface for creating
ServerCallContext from Vert.x routing context.
This interface provides an extension point for customizing how ServerCallContext
instances are created in Quarkus JSON-RPC applications. The default implementation in
A2AServerRoutes extracts standard information (user, headers, tenant, protocol version),
but applications can provide their own implementation to add custom context data.
Default Behavior
When no CDI bean implementing this interface is provided, A2AServerRoutes
creates contexts with:
- User authentication from Quarkus Security
- HTTP headers map
- Tenant ID from request path
- A2A protocol version from
X-A2A-Versionheader - Required extensions from
X-A2A-Extensionsheader
Custom Implementation Example
@ApplicationScoped
public class CustomCallContextFactory implements CallContextFactory {
@Override
public ServerCallContext build(RoutingContext rc) {
// Extract user from Quarkus security context
User user = (rc.user() == null) ? UnauthenticatedUser.INSTANCE :
new AuthenticatedUser(rc.user().subject());
// Extract custom data from routing context
String orgId = rc.request().getHeader("X-Organization-ID");
Map<String, Object> state = new HashMap<>();
state.put("organization", orgId);
state.put("requestId", UUID.randomUUID().toString());
// Extract A2A protocol version from header
String version = rc.request().getHeader(A2AHeaders.X_A2A_VERSION);
// Extract requested extensions from header
List<String> extensionHeaders = rc.request().headers().getAll(A2AHeaders.X_A2A_EXTENSIONS);
Set<String> extensions = A2AExtensions.getRequestedExtensions(extensionHeaders);
return new ServerCallContext(user, state, extensions, version);
}
}
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbuild(io.vertx.ext.web.RoutingContext rc) Builds aServerCallContextfrom a Vert.x routing context.
-
Method Details
-
build
Builds aServerCallContextfrom a Vert.x routing context.This method is called for each incoming HTTP request to create the context that will be passed to the
RequestHandlerand eventually to theAgentExecutor.- Parameters:
rc- the Vert.x routing context containing request data- Returns:
- a new ServerCallContext with extracted authentication, headers, and metadata
-