Skip to content

Commit 211efb1

Browse files
authored
Update examples/logging/jul to use Nima (helidon-io#6865)
Signed-off-by: aserkes <andrii.serkes@oracle.com>
1 parent b5b007e commit 211efb1

3 files changed

Lines changed: 19 additions & 20 deletions

File tree

examples/logging/jul/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ java -jar target/helidon-examples-logging-jul.jar
2020

2121
Expected output should be similar to the following:
2222
```text
23-
2020.11.19 15:37:28 INFO io.helidon.logging.common.LogConfig Thread[main,5,main]: Logging at initialization configured using classpath: /logging.properties ""
23+
2020.11.19 15:37:28 INFO io.helidon.logging.jul.JulProvider Thread[#1,main,5,main]: Logging at initialization configured using classpath: /logging.properties ""
2424
2020.11.19 15:37:28 INFO io.helidon.examples.logging.jul.Main Thread[main,5,main]: Starting up "startup"
2525
2020.11.19 15:37:28 INFO io.helidon.examples.logging.jul.Main Thread[pool-1-thread-1,5,main]: Running on another thread "propagated"
26-
2020.11.19 15:37:28 INFO io.helidon.common.features.HelidonFeatures Thread[features-thread,5,main]: Helidon SE 2.2.0 features: [Config, WebServer] ""
27-
2020.11.19 15:37:28 INFO io.helidon.reactive.webserver.NettyWebServer Thread[nioEventLoopGroup-2-1,10,main]: Channel '@default' started: [id: 0x8a5f5634, L:/0:0:0:0:0:0:0:0:8080] ""
26+
2020.11.19 15:37:28 INFO io.helidon.common.features.HelidonFeatures Thread[#23,features-thread,5,main]: Helidon NIMA 4.0.0-SNAPSHOT features: [Config, Encoding, Media, WebServer] ""
27+
2020.11.19 15:37:28 INFO io.helidon.nima.webserver.LoomServer Thread[#1,main,5,main]: Started all channels in 46 milliseconds. 577 milliseconds since JVM startup. Java 20.0.1+9-29 "propagated"
2828
```
2929

3030
# Running as native image

examples/logging/jul/pom.xml

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

4242
<dependencies>
4343
<dependency>
44-
<groupId>io.helidon.reactive.webserver</groupId>
45-
<artifactId>helidon-reactive-webserver</artifactId>
44+
<groupId>io.helidon.nima.webserver</groupId>
45+
<artifactId>helidon-nima-webserver</artifactId>
4646
</dependency>
4747
</dependencies>
4848

examples/logging/jul/src/main/java/io/helidon/examples/logging/jul/Main.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 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,15 +19,14 @@
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
import java.util.logging.Logger;
2423

2524
import io.helidon.common.context.Context;
2625
import io.helidon.common.context.Contexts;
2726
import io.helidon.logging.common.HelidonMdc;
2827
import io.helidon.logging.common.LogConfig;
29-
import io.helidon.reactive.webserver.Routing;
30-
import io.helidon.reactive.webserver.WebServer;
28+
import io.helidon.nima.webserver.WebServer;
29+
import io.helidon.nima.webserver.http.HttpRouting;
3130

3231
/**
3332
* Main class of the example, runnable from command line.
@@ -51,18 +50,18 @@ public static void main(String[] args) {
5150
// done by the webserver
5251
Contexts.runInContext(Context.create(), Main::logging);
5352

54-
WebServer.builder()
55-
.routing(Routing.builder()
56-
.get("/", (req, res) -> {
57-
HelidonMdc.set("name", String.valueOf(req.requestId()));
58-
LOGGER.info("Running in webserver, id:");
59-
res.send("Hello");
60-
})
61-
.build())
53+
WebServer server = WebServer.builder()
6254
.port(8080)
63-
.build()
64-
.start()
65-
.await(10, TimeUnit.SECONDS);
55+
.routing(Main::routing)
56+
.start();
57+
}
58+
59+
private static void routing(HttpRouting.Builder routing) {
60+
routing.get("/", (req, res) -> {
61+
HelidonMdc.set("name", String.valueOf(req.id()));
62+
LOGGER.info("Running in webserver, id:");
63+
res.send("Hello");
64+
});
6665
}
6766

6867
private static void logging() {

0 commit comments

Comments
 (0)