Skip to content

Commit 8900cbd

Browse files
authored
feat: add default noop providers for AgentCard and -Executor (#215)
This avoids CDI injection problems when building an application with the Quarkus plugin, and still makes people have to implement them to run their application # Description Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [x] Follow the [`CONTRIBUTING` Guide](../CONTRIBUTING.md). - [x] Make your Pull Request title in the <https://www.conventionalcommits.org/> specification. - Important Prefixes for [release-please](https://github.com/googleapis/release-please): - `fix:` which represents bug fixes, and correlates to a [SemVer](https://semver.org/) patch. - `feat:` represents a new feature, and correlates to a SemVer minor. - `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking change (indicated by the `!`) and will result in a SemVer major. - [x] Ensure the tests pass - [x] Appropriate READMEs were updated (if necessary) Fixes #213
1 parent af34181 commit 8900cbd

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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 " +
46+
"annotated implementation.";
47+
}
48+
}

0 commit comments

Comments
 (0)