diff --git a/reference-impl/src/main/java/io/a2a/server/apps/quarkus/DefaultProducers.java b/reference-impl/src/main/java/io/a2a/server/apps/quarkus/DefaultProducers.java new file mode 100644 index 000000000..2264355ac --- /dev/null +++ b/reference-impl/src/main/java/io/a2a/server/apps/quarkus/DefaultProducers.java @@ -0,0 +1,48 @@ +package io.a2a.server.apps.quarkus; + +import java.util.ArrayList; +import java.util.Collections; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Default; +import jakarta.ws.rs.Produces; + +import io.a2a.server.PublicAgentCard; +import io.a2a.server.agentexecution.AgentExecutor; +import io.a2a.server.agentexecution.RequestContext; +import io.a2a.server.events.EventQueue; +import io.a2a.spec.AgentCapabilities; +import io.a2a.spec.AgentCard; +import io.a2a.spec.JSONRPCError; +import io.quarkus.arc.DefaultBean; + +/** + * Contains beans annotated with the Quarkus @DefaultBean annotation, in order to avoid + * injection failures when building the Quarkus application as discussed in + * Issue 213. + * + * If an application provides actual implementations of these beans, + * those will be used instead. + */ +@ApplicationScoped +public class DefaultProducers { + @Produces + @PublicAgentCard + @DefaultBean + public AgentCard createDefaultAgentCard() { + throw new IllegalStateException(wrap("Please provide your own AgentCard implementation")); + } + + @Produces + @Default + @DefaultBean + public AgentExecutor createDefaultAgentExecutor() { + throw new IllegalStateException(wrap("Please provide your own AgentExecutor implementation")); + } + + private String wrap(String s) { + return s + + " as a CDI bean. Your bean will automatically take precedence over this @DefaultBean " + + "annotated implementation."; + } +}