|
| 1 | +package io.a2a.server.apps.quarkus; |
| 2 | + |
| 3 | +import java.util.ArrayList; |
| 4 | +import java.util.Collections; |
| 5 | + |
| 6 | +import jakarta.enterprise.context.ApplicationScoped; |
| 7 | +import jakarta.enterprise.inject.Default; |
| 8 | +import jakarta.ws.rs.Produces; |
| 9 | + |
| 10 | +import io.a2a.server.PublicAgentCard; |
| 11 | +import io.a2a.server.agentexecution.AgentExecutor; |
| 12 | +import io.a2a.server.agentexecution.RequestContext; |
| 13 | +import io.a2a.server.events.EventQueue; |
| 14 | +import io.a2a.spec.AgentCapabilities; |
| 15 | +import io.a2a.spec.AgentCard; |
| 16 | +import io.a2a.spec.JSONRPCError; |
| 17 | +import io.quarkus.arc.DefaultBean; |
| 18 | + |
| 19 | +/** |
| 20 | + * Contains beans annotated with the Quarkus @DefaultBean annotation, in order to avoid |
| 21 | + * injection failures when building the Quarkus application as discussed in |
| 22 | + * <a href="https://github.com/a2aproject/a2a-java/issues/213">Issue 213</a>. |
| 23 | + * |
| 24 | + * If an application provides actual implementations of these beans, |
| 25 | + * those will be used instead. |
| 26 | + */ |
| 27 | +@ApplicationScoped |
| 28 | +public class DefaultProducers { |
| 29 | + @Produces |
| 30 | + @PublicAgentCard |
| 31 | + @DefaultBean |
| 32 | + public AgentCard createDefaultAgentCard() { |
| 33 | + throw new IllegalStateException(wrap("Please provide your own AgentCard implementation")); |
| 34 | + } |
| 35 | + |
| 36 | + @Produces |
| 37 | + @Default |
| 38 | + @DefaultBean |
| 39 | + public AgentExecutor createDefaultAgentExecutor() { |
| 40 | + throw new IllegalStateException(wrap("Please provide your own AgentExecutor implementation")); |
| 41 | + } |
| 42 | + |
| 43 | + private String wrap(String s) { |
| 44 | + return s + |
| 45 | + " as a CDI bean. Your bean will automatically take precedence over this @DefaultBean annotated" + |
| 46 | + "implementation."; |
| 47 | + } |
| 48 | +} |
0 commit comments