@@ -44,7 +44,7 @@ class WidgetController(private val hello: HelloComponent) {
4444
4545```
4646
47- ## Generated source
47+ ## Generated source ( Javalin )
4848
4949The annotation processor will generate a `$Route` for the controller like below.
5050
@@ -55,7 +55,7 @@ get all the WebRoutes and register them with Javalin using.
5555fun main (args : Array<String > ) {
5656
5757 // get all the webRoutes
58- val webRoutes = ApplicationScope .list (WebRoutes ::class .java )
58+ val webRoutes = BeanScope . builder() . build() . list(WebRoutes :: class. java)
5959
6060 val javalin = Javalin . create()
6161
@@ -76,7 +76,7 @@ fun main(args: Array<String>) {
7676
7777```
7878
79- ### The generated WidgetController $Route . java is:
79+ ### ( Javalin ) The generated WidgetController $Route . java is:
8080
8181
8282```java
@@ -117,6 +117,68 @@ public class WidgetController$Route implements WebRoutes {
117117}
118118```
119119
120+ ## Generated source (Helidon SE )
121+
122+ The annotation processor will generate a `$Route` for the controller like below.
123+
124+ Note that this class implements the Helidon Service interface, which means we can
125+ get all the Services and register them with Helidon `RoutingBuilder`.
126+
127+ ```
128+ var routes = BeanScope.builder ().build ().list (Service .class );
129+ var routingBuilder = Routing.builder ().register (routes .stream ().toArray (Service []::new ));
130+ WebServer.builder ()
131+ .addMediaSupport (JacksonSupport .create ())
132+ .routing (routingBuilder )
133+ .build ()
134+ .start ();
135+ ```
136+ ### (Helidon SE ) The generated WidgetController $Route . java is:
137+
138+ ```java
139+ package org. example. hello;
140+
141+ import static io.avaje.http.api. PathTypeConversion . * ;
142+
143+ import io. avaje. http. api. * ;
144+ import io.helidon.common.http. FormParams ;
145+ import io.helidon.webserver. Handler ;
146+ import io.helidon.webserver. Routing ;
147+ import io.helidon.webserver. ServerRequest ;
148+ import io.helidon.webserver. ServerResponse ;
149+ import io.helidon.webserver. Service ;
150+ import jakarta.inject. Singleton ;
151+ import org.example.hello. WidgetController ;
152+
153+ @Generated (" io.dinject.helidon-generator" )
154+ @Singleton
155+ public class WidgetController $Route implements Service {
156+
157+ private final WidgetController controller;
158+
159+ public WidgetController$Route (WidgetController controller ) {
160+ this . controller = controller;
161+ }
162+
163+ @Override
164+ public void update (Routing .Rules rules ) {
165+
166+ rules. get(" /widgets/:id" , this :: _getById);
167+ rules. post(" /widgets" , this :: _getAll);
168+ }
169+
170+ private void _getById (ServerRequest req , ServerResponse res ) {
171+ int id = asInt(req. path(). param(" id" ));
172+ res. send(controller. getById(id));
173+ }
174+
175+ private void _getAll (ServerRequest req , ServerResponse res ) {
176+ res. send(controller. getAll());
177+ }
178+
179+ }
180+ ```
181+
120182Note that this APT processor works with both Java and Kotlin .
121183
122184
0 commit comments