Skip to content

Commit d07d150

Browse files
aserkesdalexandrov
authored andcommitted
Update examples/logging/logback-aot to use Nima (helidon-io#6866)
Signed-off-by: aserkes <[email protected]>
1 parent ca8621f commit d07d150

File tree

3 files changed

+24
-25
lines changed

3 files changed

+24
-25
lines changed

examples/logging/logback-aot/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ Within 30 seconds the configuration should be reloaded, and next request will ha
1818

1919
Expected output should be similar to the following (for both hotspot and native):
2020
```text
21-
15:40:44.240 INFO [main] i.h.examples.logging.slf4j.Main - Starting up startup
22-
15:40:44.241 INFO [main] i.h.examples.logging.slf4j.Main - Using JUL logger startup
23-
15:40:44.245 INFO [pool-1-thread-1] i.h.examples.logging.slf4j.Main - Running on another thread propagated
24-
15:40:44.395 INFO [features-thread] io.helidon.common.features.HelidonFeatures - Helidon SE 2.2.0 features: [Config, WebServer]
25-
15:40:44.538 INFO [nioEventLoopGroup-2-1] io.helidon.reactive.webserver.NettyWebServer - Channel '@default' started: [id: 0x8e516487, L:/0:0:0:0:0:0:0:0:8080]
21+
15:40:44.240 [INFO ] [io.helidon.examples.logging.logback.aot.Main.logging:128] Starting up startup
22+
15:40:44.241 [INFO ] [o.slf4j.jdk.platform.logging.SLF4JPlatformLogger.performLog:151] Using System logger startup
23+
15:40:44.245 [INFO ] [io.helidon.examples.logging.logback.aot.Main.log:146] Running on another thread propagated
24+
15:40:44.395 [INFO ] [o.slf4j.jdk.platform.logging.SLF4JPlatformLogger.performLog:151] Helidon NIMA 4.0.0-SNAPSHOT features: [Config, Encoding, Media, WebServer]
25+
15:40:44.538 [INFO ] [o.slf4j.jdk.platform.logging.SLF4JPlatformLogger.performLog:151] Started all channels in 15 milliseconds. 647 milliseconds since JVM startup. Java 20.0.1+9-29 propagated
2626
```
2727

2828
The output is also logged into `helidon.log`.
@@ -36,7 +36,7 @@ mvn clean package
3636

3737
Run from command line:
3838
```shell script
39-
java -jar target/helidon-examples-logging-sfl4j.jar
39+
java -jar target/helidon-examples-logging-slf4j-aot.jar
4040
```
4141

4242
Execute endpoint:

examples/logging/logback-aot/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242

4343
<dependencies>
4444
<dependency>
45-
<groupId>io.helidon.reactive.webserver</groupId>
46-
<artifactId>helidon-reactive-webserver</artifactId>
45+
<groupId>io.helidon.nima.webserver</groupId>
46+
<artifactId>helidon-nima-webserver</artifactId>
4747
</dependency>
4848
<dependency>
4949
<groupId>io.helidon.logging</groupId>

examples/logging/logback-aot/src/main/java/io/helidon/examples/logging/logback/aot/Main.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,13 +19,12 @@
1919
import java.util.concurrent.ExecutorService;
2020
import java.util.concurrent.Executors;
2121
import java.util.concurrent.Future;
22-
import java.util.concurrent.TimeUnit;
2322

2423
import io.helidon.common.context.Context;
2524
import io.helidon.common.context.Contexts;
2625
import io.helidon.logging.common.HelidonMdc;
27-
import io.helidon.reactive.webserver.Routing;
28-
import io.helidon.reactive.webserver.WebServer;
26+
import io.helidon.nima.webserver.WebServer;
27+
import io.helidon.nima.webserver.http.HttpRouting;
2928

3029
import ch.qos.logback.classic.LoggerContext;
3130
import ch.qos.logback.classic.joran.JoranConfigurator;
@@ -60,20 +59,20 @@ public static void main(String[] args) {
6059
// done by the webserver
6160
Contexts.runInContext(Context.create(), Main::logging);
6261

63-
WebServer.builder()
64-
.routing(Routing.builder()
65-
.get("/", (req, res) -> {
66-
HelidonMdc.set("name", String.valueOf(req.requestId()));
67-
LOGGER.debug("Debug message to show runtime reloading works");
68-
LOGGER.info("Running in webserver, id:");
69-
res.send("Hello")
70-
.forSingle(ignored -> LOGGER.debug("Response sent"));
71-
})
72-
.build())
62+
WebServer server = WebServer.builder()
7363
.port(8080)
74-
.build()
75-
.start()
76-
.await(10, TimeUnit.SECONDS);
64+
.routing(Main::routing)
65+
.start();
66+
}
67+
68+
private static void routing(HttpRouting.Builder routing) {
69+
routing.get("/", (req, res) -> {
70+
HelidonMdc.set("name", String.valueOf(req.id()));
71+
LOGGER.debug("Debug message to show runtime reloading works");
72+
LOGGER.info("Running in webserver, id:");
73+
res.send("Hello");
74+
LOGGER.debug("Response sent");
75+
});
7776
}
7877

7978
private static void setupLogging() {

0 commit comments

Comments
 (0)