Skip to content

Commit 50c9f7d

Browse files
committed
Upgrade to 0.3.0.Final of the SDK and make necessary changes
1 parent f7e07ce commit 50c9f7d

File tree

9 files changed

+85
-10
lines changed

9 files changed

+85
-10
lines changed

examples/simple/client/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@
5454
<groupId>com.google.guava</groupId>
5555
<artifactId>failureaccess</artifactId>
5656
</dependency>
57+
<!-- SLF4J implementation for gRPC logging -->
58+
<dependency>
59+
<groupId>org.slf4j</groupId>
60+
<artifactId>slf4j-simple</artifactId>
61+
<version>2.0.17</version>
62+
</dependency>
5763
</dependencies>
5864

5965
<build>

impl/grpc/src/main/java/org/wildfly/extras/a2a/server/apps/grpc/GrpcBeanInitializer.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.wildfly.extras.a2a.server.apps.grpc;
22

3+
import java.util.concurrent.Executor;
4+
35
import jakarta.annotation.PreDestroy;
46
import jakarta.enterprise.context.ApplicationScoped;
57
import jakarta.enterprise.context.Initialized;
@@ -9,6 +11,7 @@
911

1012
import io.a2a.server.PublicAgentCard;
1113
import io.a2a.server.requesthandlers.RequestHandler;
14+
import io.a2a.server.util.async.Internal;
1215
import io.a2a.spec.AgentCard;
1316
import io.a2a.transport.grpc.handler.CallContextFactory;
1417

@@ -32,6 +35,10 @@ public class GrpcBeanInitializer {
3235
@Inject
3336
Instance<CallContextFactory> callContextFactory;
3437

38+
@Inject
39+
@Internal
40+
Executor executor;
41+
3542
/**
3643
* Observes the application startup event to eagerly initialize the gRPC cache.
3744
*/
@@ -40,8 +47,8 @@ public void onStartup(@Observes @Initialized(ApplicationScoped.class) Object ini
4047
try {
4148
// Cache CDI beans for gRPC threads to use since CDI is not available on those threads
4249
CallContextFactory ccf = callContextFactory.isUnsatisfied() ? null : callContextFactory.get();
43-
WildFlyGrpcHandler.setStaticBeans(agentCard, requestHandler, ccf);
44-
System.out.println("*** GrpcBeanInitializer successfully cached beans: agentCard=" + agentCard + ", requestHandler=" + requestHandler + ", callContextFactory=" + ccf + " ***");
50+
WildFlyGrpcHandler.setStaticBeans(agentCard, requestHandler, ccf, executor);
51+
System.out.println("*** GrpcBeanInitializer successfully cached beans: agentCard=" + agentCard + ", requestHandler=" + requestHandler + ", callContextFactory=" + ccf + ", executor=" + executor + " ***");
4552
} catch (Exception e) {
4653
System.err.println("*** GrpcBeanInitializer.onStartup() failed: " + e.getMessage());
4754
e.printStackTrace();
@@ -50,6 +57,6 @@ public void onStartup(@Observes @Initialized(ApplicationScoped.class) Object ini
5057

5158
@PreDestroy
5259
public void cleanup() {
53-
WildFlyGrpcHandler.setStaticBeans(null, null, null);
60+
WildFlyGrpcHandler.setStaticBeans(null, null, null, null);
5461
}
5562
}

impl/grpc/src/main/java/org/wildfly/extras/a2a/server/apps/grpc/WildFlyGrpcHandler.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package org.wildfly.extras.a2a.server.apps.grpc;
22

3+
import java.util.concurrent.Executor;
4+
5+
import jakarta.inject.Inject;
6+
37
import io.a2a.server.requesthandlers.RequestHandler;
8+
import io.a2a.server.util.async.Internal;
49
import io.a2a.spec.AgentCard;
510
import io.a2a.transport.grpc.handler.CallContextFactory;
611
import io.a2a.transport.grpc.handler.GrpcHandler;
@@ -20,6 +25,7 @@ public class WildFlyGrpcHandler extends GrpcHandler {
2025
private static volatile AgentCard staticAgentCard;
2126
private static volatile RequestHandler staticRequestHandler;
2227
private static volatile CallContextFactory staticCallContextFactory;
28+
private static volatile Executor staticExecutor;
2329

2430
public WildFlyGrpcHandler() {
2531
// Default constructor - the only one used by WildFly gRPC subsystem
@@ -29,10 +35,11 @@ public WildFlyGrpcHandler() {
2935
* Called by GrpcBeanInitializer during CDI initialization to cache beans
3036
* for use by gRPC threads where CDI is not available.
3137
*/
32-
static void setStaticBeans(AgentCard agentCard, RequestHandler requestHandler, CallContextFactory callContextFactory) {
38+
static void setStaticBeans(AgentCard agentCard, RequestHandler requestHandler, CallContextFactory callContextFactory, Executor executor) {
3339
staticAgentCard = agentCard;
3440
staticRequestHandler = requestHandler;
3541
staticCallContextFactory = callContextFactory;
42+
staticExecutor = executor;
3643
}
3744

3845
@Override
@@ -55,4 +62,12 @@ protected AgentCard getAgentCard() {
5562
protected CallContextFactory getCallContextFactory() {
5663
return staticCallContextFactory; // Can be null if not configured
5764
}
65+
66+
@Override
67+
protected Executor getExecutor() {
68+
if (staticExecutor == null) {
69+
throw new RuntimeException("Executor not available. ApplicationStartup may not have run yet.");
70+
}
71+
return staticExecutor;
72+
}
5873
}

impl/jsonrpc/src/main/java/org/wildfly/extras/a2a/server/apps/jakarta/A2AServerResource.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import java.io.IOException;
44
import java.io.PrintWriter;
5+
import java.util.ArrayList;
56
import java.util.Enumeration;
67
import java.util.HashMap;
8+
import java.util.List;
79
import java.util.Map;
10+
import java.util.Set;
811
import java.util.concurrent.CompletableFuture;
912
import java.util.concurrent.Executor;
1013
import java.util.concurrent.Flow;
@@ -31,10 +34,12 @@
3134
import com.fasterxml.jackson.core.JsonParseException;
3235
import com.fasterxml.jackson.databind.JsonMappingException;
3336
import com.fasterxml.jackson.databind.ObjectMapper;
37+
import io.a2a.common.A2AHeaders;
3438
import io.a2a.server.ExtendedAgentCard;
3539
import io.a2a.server.ServerCallContext;
3640
import io.a2a.server.auth.UnauthenticatedUser;
3741
import io.a2a.server.auth.User;
42+
import io.a2a.server.extensions.A2AExtensions;
3843
import io.a2a.server.util.async.Internal;
3944
import io.a2a.spec.AgentCard;
4045
import io.a2a.spec.CancelTaskRequest;
@@ -333,7 +338,13 @@ public String getUsername() {
333338

334339
state.put("headers", headers);
335340

336-
return new ServerCallContext(user, state);
341+
Enumeration<String> en = request.getHeaders(A2AHeaders.X_A2A_EXTENSIONS);
342+
List<String> extensionHeaderValues = new ArrayList<>();
343+
while (en.hasMoreElements()) {
344+
extensionHeaderValues.add(en.nextElement());
345+
}
346+
Set<String> requestedExtensions = A2AExtensions.getRequestedExtensions(extensionHeaderValues);
347+
return new ServerCallContext(user, state, requestedExtensions);
337348
} else {
338349
CallContextFactory builder = callContextFactory.get();
339350
return builder.build(request);

impl/rest/src/main/java/org/wildfly/extras/a2a/server/apps/rest/A2ARestServerResource.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55

66
import java.io.IOException;
77
import java.io.PrintWriter;
8+
import java.util.ArrayList;
89
import java.util.Enumeration;
910
import java.util.HashMap;
11+
import java.util.List;
1012
import java.util.Map;
13+
import java.util.Set;
1114
import java.util.concurrent.CompletableFuture;
1215
import java.util.concurrent.Executor;
1316
import java.util.concurrent.Flow;
@@ -25,10 +28,13 @@
2528
import jakarta.ws.rs.core.MediaType;
2629
import jakarta.ws.rs.core.Response;
2730
import jakarta.ws.rs.core.SecurityContext;
31+
32+
import io.a2a.common.A2AHeaders;
2833
import io.a2a.server.ExtendedAgentCard;
2934
import io.a2a.server.ServerCallContext;
3035
import io.a2a.server.auth.UnauthenticatedUser;
3136
import io.a2a.server.auth.User;
37+
import io.a2a.server.extensions.A2AExtensions;
3238
import io.a2a.server.util.async.Internal;
3339
import io.a2a.spec.AgentCard;
3440
import io.a2a.spec.InvalidParamsError;
@@ -177,7 +183,7 @@ public Response getTask(@PathParam("taskId") String taskId, @QueryParam("history
177183
ServerCallContext context = createCallContext(httpRequest, securityContext);
178184
RestHandler.HTTPRestResponse response = null;
179185
try {
180-
Integer historyLength = null;
186+
int historyLength = 0;
181187
if (history_length != null) {
182188
historyLength = Integer.valueOf(history_length);
183189
}
@@ -344,7 +350,13 @@ public String getUsername() {
344350

345351
state.put("headers", headers);
346352

347-
return new ServerCallContext(user, state);
353+
Enumeration<String> en = request.getHeaders(A2AHeaders.X_A2A_EXTENSIONS);
354+
List<String> extensionHeaderValues = new ArrayList<>();
355+
while (en.hasMoreElements()) {
356+
extensionHeaderValues.add(en.nextElement());
357+
}
358+
Set<String> requestedExtensions = A2AExtensions.getRequestedExtensions(extensionHeaderValues);
359+
return new ServerCallContext(user, state, requestedExtensions);
348360
} else {
349361
CallContextFactory builder = callContextFactory.get();
350362
return builder.build(request);

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<groupId>org.wildfly.a2a</groupId>
1414
<artifactId>a2a-java-sdk-jakarta-parent</artifactId>
15-
<version>0.3.0.Beta2-SNAPSHOT</version>
15+
<version>0.3.0.Beta3</version>
1616

1717
<packaging>pom</packaging>
1818

@@ -44,8 +44,8 @@
4444

4545
<properties>
4646
<jboss.home>${project.build.directory}${file.separator}wildfly</jboss.home>
47-
<version.wildfly>36.0.1.Final</version.wildfly>
48-
<version.sdk>0.3.0.Beta2-SNAPSHOT</version.sdk>
47+
<version.wildfly>38.0.0.Final</version.wildfly>
48+
<version.sdk>0.3.2.Final</version.sdk>
4949
<!-- This needs to be same version as used by the sdk -->
5050
<version.mutiny-zero>1.1.1</version.mutiny-zero>
5151
<!-- gRPC version matching the a2a-java-sdk -->

tests/grpc/src/test/java/org/wildfly/extras/a2a/server/grpc/wildfly/A2ATestResource.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ public Response getStreamingSubscribedCount() {
105105
return Response.ok(String.valueOf(streamingSubscribedCount.get()), TEXT_PLAIN).build();
106106
}
107107

108+
@GET
109+
@Path("/queue/childCount/{taskId}")
110+
@Produces(TEXT_PLAIN)
111+
public Response getChildQueueCount(@PathParam("taskId") String taskId) {
112+
int count = testUtilsBean.getChildQueueCount(taskId);
113+
return Response.ok(String.valueOf(count), TEXT_PLAIN).build();
114+
}
115+
108116
@DELETE
109117
@Path("/task/{taskId}/config/{configId}")
110118
public Response deleteTaskPushNotificationConfig(@PathParam("taskId") String taskId, @PathParam("configId") String configId) {

tests/jsonrpc/src/test/java/org/wildfly/extras/a2a/test/server/apps/jakarta/A2ATestResource.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ public Response getStreamingSubscribedCount() {
107107
return Response.ok(String.valueOf(streamingSubscribedCount.get()), TEXT_PLAIN).build();
108108
}
109109

110+
@GET
111+
@Path("/queue/childCount/{taskId}")
112+
@Produces(TEXT_PLAIN)
113+
public Response getChildQueueCount(@PathParam("taskId") String taskId) {
114+
int count = testUtilsBean.getChildQueueCount(taskId);
115+
return Response.ok(String.valueOf(count), TEXT_PLAIN).build();
116+
}
117+
110118
@DELETE
111119
@Path("/task/{taskId}/config/{configId}")
112120
public Response deleteTaskPushNotificationConfig(@PathParam("taskId") String taskId, @PathParam("configId") String configId) {

tests/rest/src/test/java/org/wildfly/extras/a2a/test/server/apps/rest/A2ATestResource.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ public Response getStreamingSubscribedCount() {
107107
return Response.ok(String.valueOf(streamingSubscribedCount.get()), TEXT_PLAIN).build();
108108
}
109109

110+
@GET
111+
@Path("/queue/childCount/{taskId}")
112+
@Produces(TEXT_PLAIN)
113+
public Response getChildQueueCount(@PathParam("taskId") String taskId) {
114+
int count = testUtilsBean.getChildQueueCount(taskId);
115+
return Response.ok(String.valueOf(count), TEXT_PLAIN).build();
116+
}
117+
110118
@DELETE
111119
@Path("/task/{taskId}/config/{configId}")
112120
public Response deleteTaskPushNotificationConfig(@PathParam("taskId") String taskId, @PathParam("configId") String configId) {

0 commit comments

Comments
 (0)