Skip to content

Commit 91e94cb

Browse files
authored
Conditionally add BeanTypes annotation in ControllerWriter (#691)
* Conditionally add BeanTypes annotation in ControllerWriter * Update ControllerWriter.java
1 parent bcabc16 commit 91e94cb

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ 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();
121+
if (diAnnotation().equals("@Component")) {
122+
writer.append("@io.avaje.inject.BeanTypes({%s$Route.class, HttpFeature.class})", shortName).eol();
123+
}
122124
writer.append("public final class %s$Route implements HttpFeature {", shortName).eol().eol();
123125

124126
var controllerName = "controller";

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ private void writeRouting(MethodReader method) {
8181

8282
private void writeClassStart() {
8383
writer.append(AT_GENERATED).eol();
84-
writer.append(diAnnotation()).eol();
85-
writer.append("@io.avaje.inject.BeanTypes({%s$Route.class, Routing.HttpService.class})", shortName).eol();
84+
writer.append(diAnnotation()).eol();
85+
if (diAnnotation().equals("@Component")) {
86+
writer.append("@io.avaje.inject.BeanTypes({%s$Route.class, Routing.HttpService.class})", shortName).eol();
87+
}
8688
writer.append("public final class %s$Route implements Routing.HttpService {", shortName).eol().eol();
8789

8890
String controllerName = "controller";

0 commit comments

Comments
 (0)