Skip to content

Commit 376bbaf

Browse files
authored
Minimise types registered with avaje-inject for generated Routers (#690)
Use `@BeanTypes` on the generated routers for Jex and Helidon to reduce the number of types registered with avaje-inject. Helidon in particular, without this generates: ``` builder.isBeanAbsent(FooController$Route.class, HttpFeature.class, TYPE_SupplierHttpFeature, Supplier.class, ServerLifecycle.class) ``` and with this change we get: ``` builder.isBeanAbsent(FooController$Route.class, HttpFeature.class) ```
1 parent f1336b2 commit 376bbaf

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

http-generator-helidon/src/main/java/io/avaje/http/generator/helidon/nima/ControllerWriter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ private void writeRoutes(List<ControllerMethodWriter> methods) {
118118
private void writeClassStart() {
119119
writer.append(AT_GENERATED).eol();
120120
writer.append(diAnnotation()).eol();
121+
writer.append("@io.avaje.inject.BeanTypes({%s$Route.class, HttpFeature.class})", shortName).eol();
121122
writer.append("public final class %s$Route implements HttpFeature {", shortName).eol().eol();
122123

123124
var controllerName = "controller";

http-generator-jex/src/main/java/io/avaje/http/generator/jex/ControllerWriter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ private void writeRouting(MethodReader method) {
8282
private void writeClassStart() {
8383
writer.append(AT_GENERATED).eol();
8484
writer.append(diAnnotation()).eol();
85-
writer.append("public final class ").append(shortName).append("$Route implements Routing.HttpService {").eol().eol();
85+
writer.append("@io.avaje.inject.BeanTypes({%s$Route.class, Routing.HttpService.class})", shortName).eol();
86+
writer.append("public final class %s$Route implements Routing.HttpService {", shortName).eol().eol();
8687

8788
String controllerName = "controller";
8889
String controllerType = shortName;

0 commit comments

Comments
 (0)