Skip to content

Commit 5b16f79

Browse files
committed
Upgrade to Helidon 4 and move to WME version 2.2
1 parent 72afc8d commit 5b16f79

File tree

12 files changed

+195
-139
lines changed

12 files changed

+195
-139
lines changed

build-helper-mojo/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<artifactId>wls-exporter-parent</artifactId>
1111
<groupId>com.oracle.wls.exporter</groupId>
12-
<version>2.1.10-SNAPSHOT</version>
12+
<version>2.2.0-SNAPSHOT</version>
1313
</parent>
1414

1515
<artifactId>build-helper-mojo</artifactId>

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<groupId>com.oracle.wls.exporter</groupId>
99
<artifactId>wls-exporter-parent</artifactId>
10-
<version>2.1.10-SNAPSHOT</version>
10+
<version>2.2.0-SNAPSHOT</version>
1111
<modules>
1212
<module>build-helper-mojo</module>
1313
<module>wls-exporter-core</module>
@@ -339,7 +339,7 @@
339339
<dependency>
340340
<groupId>org.slf4j</groupId>
341341
<artifactId>slf4j-nop</artifactId>
342-
<version>2.0.11</version>
342+
<version>2.0.12</version>
343343
<scope>test</scope>
344344
</dependency>
345345
<dependency>
@@ -350,7 +350,7 @@
350350
<dependency>
351351
<groupId>org.junit.jupiter</groupId>
352352
<artifactId>junit-jupiter</artifactId>
353-
<version>5.10.1</version>
353+
<version>5.10.2</version>
354354
<scope>test</scope>
355355
</dependency>
356356
<dependency>

wls-exporter-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<artifactId>wls-exporter-parent</artifactId>
1010
<groupId>com.oracle.wls.exporter</groupId>
11-
<version>2.1.10-SNAPSHOT</version>
11+
<version>2.2.0-SNAPSHOT</version>
1212
</parent>
1313

1414
<artifactId>wls-exporter-core</artifactId>

wls-exporter-sidecar/pom.xml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
<parent>
99
<groupId>com.oracle.wls.exporter</groupId>
1010
<artifactId>wls-exporter-parent</artifactId>
11-
<version>2.1.10-SNAPSHOT</version>
11+
<version>2.2.0-SNAPSHOT</version>
1212
</parent>
1313
<artifactId>wls-exporter-sidecar</artifactId>
1414
<name>WebLogic Monitoring Exporter Sidecar</name>
1515

1616
<properties>
17-
<helidon.version>3.2.5</helidon.version>
17+
<helidon.version>4.0.5</helidon.version>
1818
<mainClass>com.oracle.wls.exporter.sidecar.Main</mainClass>
1919

20-
<version.plugin.helidon>3.0.7</version.plugin.helidon>
20+
<version.plugin.helidon>4.0.5</version.plugin.helidon>
2121
</properties>
2222

2323
<dependencyManagement>
@@ -97,8 +97,13 @@
9797
<scope>test</scope>
9898
</dependency>
9999
<dependency>
100-
<groupId>io.helidon.webserver</groupId>
101-
<artifactId>helidon-webserver-test-support</artifactId>
100+
<groupId>io.helidon.webserver.testing.junit5</groupId>
101+
<artifactId>helidon-webserver-testing-junit5</artifactId>
102+
<scope>test</scope>
103+
</dependency>
104+
<dependency>
105+
<artifactId>helidon-logging-jul</artifactId>
106+
<groupId>io.helidon.logging</groupId>
102107
<scope>test</scope>
103108
</dependency>
104109
<dependency>

wls-exporter-sidecar/src/main/java/com/oracle/wls/exporter/sidecar/HelidonInvocationContext.java

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1-
// Copyright (c) 2021, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2021, 2024, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package com.oracle.wls.exporter.sidecar;
55

6-
import java.io.ByteArrayInputStream;
76
import java.io.ByteArrayOutputStream;
87
import java.io.InputStream;
98
import java.io.PrintStream;
109
import java.net.URI;
11-
import java.util.concurrent.TimeUnit;
1210

1311
import com.oracle.wls.exporter.InvocationContext;
1412
import com.oracle.wls.exporter.UrlBuilder;
15-
import com.oracle.wls.exporter.WebAppConstants;
16-
import io.helidon.common.http.DataChunk;
17-
import io.helidon.common.http.Http;
18-
import io.helidon.common.http.MediaType;
19-
import io.helidon.common.reactive.Single;
20-
import io.helidon.webserver.ServerRequest;
21-
import io.helidon.webserver.ServerResponse;
13+
import io.helidon.http.HeaderNames;
14+
import io.helidon.common.media.type.MediaType;
15+
import io.helidon.http.Status;
16+
import io.helidon.webserver.http.ServerRequest;
17+
import io.helidon.webserver.http.ServerResponse;
2218

2319
public class HelidonInvocationContext implements InvocationContext {
2420

@@ -47,7 +43,7 @@ public String getApplicationContext() {
4743

4844
@Override
4945
public String getAuthenticationHeader() {
50-
return request.headers().first(WebAppConstants.AUTHENTICATION_HEADER).orElse(null);
46+
return request.headers().first(HeaderNames.AUTHORIZATION).orElse(null);
5147
}
5248

5349
@Override
@@ -62,10 +58,7 @@ public String getInstanceName() {
6258

6359
@Override
6460
public InputStream getRequestStream() {
65-
return request.content().as(String.class)
66-
.thenApply(String::getBytes)
67-
.thenApply(ByteArrayInputStream::new)
68-
.await(10, TimeUnit.SECONDS);
61+
return request.content().inputStream();
6962
}
7063

7164
@Override
@@ -82,12 +75,12 @@ public void sendError(int status, String msg) {
8275
public void sendRedirect(String location) {
8376
response.headers().location(URI.create(location));
8477

85-
response.status(Http.Status.FOUND_302).send();
78+
response.status(Status.FOUND_302).send();
8679
}
8780

8881
@Override
8982
public void setResponseHeader(String name, String value) {
90-
response.headers().add(name, value);
83+
response.headers().add(HeaderNames.create(name), value);
9184
}
9285

9386
@Override
@@ -97,6 +90,8 @@ public void setStatus(int status) {
9790

9891
@Override
9992
public void close() {
100-
response.send(Single.just(DataChunk.create(baos.toByteArray())));
93+
if (!response.isSent()) {
94+
response.send(baos.toByteArray());
95+
}
10196
}
10297
}
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
// Copyright (c) 2021, Oracle and/or its affiliates.
1+
// Copyright (c) 2021, 2024, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package com.oracle.wls.exporter.sidecar;
55

6-
import java.util.concurrent.TimeUnit;
7-
86
import com.oracle.wls.exporter.WebClientFactoryImpl;
9-
import io.helidon.common.LogConfig;
10-
import io.helidon.webserver.Routing;
7+
import io.helidon.logging.common.LogConfig;
118
import io.helidon.webserver.WebServer;
9+
import io.helidon.webserver.http.HttpRouting;
1210

1311

1412
// Main program for the Exporter sidecar using Helidon
@@ -19,10 +17,9 @@ public static void main(String[] args) {
1917
final MetricsService metricsService = new MetricsService(configuration, new WebClientFactoryImpl());
2018

2119
WebServer.builder()
22-
.addRouting(Routing.builder().register(metricsService).build())
20+
.addRouting(HttpRouting.builder().register(metricsService))
2321
.port(metricsService.getListenPort())
2422
.build()
25-
.start()
26-
.await(10, TimeUnit.SECONDS);
23+
.start();
2724
}
2825
}

wls-exporter-sidecar/src/main/java/com/oracle/wls/exporter/sidecar/MetricsService.java

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
// Copyright (c) 2021, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2021, 2024, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package com.oracle.wls.exporter.sidecar;
55

66
import java.io.IOException;
7-
import java.util.concurrent.ExecutorService;
87
import java.util.function.BiFunction;
98

109
import com.oracle.wls.exporter.AuthenticatedCall;
@@ -15,16 +14,15 @@
1514
import com.oracle.wls.exporter.LiveConfiguration;
1615
import com.oracle.wls.exporter.MessagesCall;
1716
import com.oracle.wls.exporter.WebClientFactory;
18-
import io.helidon.common.configurable.ThreadPoolSupplier;
19-
import io.helidon.webserver.Routing;
20-
import io.helidon.webserver.ServerRequest;
21-
import io.helidon.webserver.ServerResponse;
22-
import io.helidon.webserver.Service;
17+
import io.helidon.webserver.http.Handler;
18+
import io.helidon.webserver.http.ServerRequest;
19+
import io.helidon.webserver.http.ServerResponse;
20+
import io.helidon.webserver.http.HttpRules;
21+
import io.helidon.webserver.http.HttpService;
2322

24-
class MetricsService implements Service {
23+
class MetricsService implements HttpService {
2524

2625
private final WebClientFactory webClientFactory;
27-
private final ExecutorService executorService;
2826

2927
private final AuthenticatedHandler metricsHandler = new AuthenticatedHandler(ExporterCall::new);
3028
private final AuthenticatedHandler configurationHandler = new AuthenticatedHandler(ConfigurationPutCall::new);
@@ -36,37 +34,27 @@ class MetricsService implements Service {
3634
this.listenPort = configuration.getListenPort();
3735
this.webClientFactory = webClientFactory;
3836
LiveConfiguration.setServer(configuration.getWebLogicHost(), configuration.getWebLogicPort());
39-
40-
this.executorService = ThreadPoolSupplier.builder()
41-
.threadNamePrefix("wls-exporter-sidecar-")
42-
.corePoolSize(10)
43-
.prestart(true)
44-
.build()
45-
.get();
4637
}
4738

4839
@Override
49-
public void update(Routing.Rules rules) {
50-
rules
51-
.get("/", mainHandler::dispatch)
52-
.get("/metrics", metricsHandler::dispatch)
53-
.get("/messages", messagesHandler::dispatch)
54-
.put("/configuration", configurationHandler::dispatch);
40+
public void routing(HttpRules rules) {
41+
rules.get("/", mainHandler)
42+
.get("/metrics", metricsHandler)
43+
.get("/messages", messagesHandler)
44+
.put("/configuration", configurationHandler);
5545
}
5646

5747
int getListenPort() {
5848
return listenPort;
5949
}
6050

61-
abstract class Handler {
62-
void dispatch(ServerRequest request, ServerResponse response) {
63-
executorService.submit(() -> {
64-
try {
65-
invoke(new HelidonInvocationContext(request, response));
66-
} catch (IOException e) {
67-
reportServerFailure(response, e);
68-
}
69-
});
51+
abstract class MyHandler implements Handler {
52+
public void handle(ServerRequest request, ServerResponse response) {
53+
try {
54+
invoke(new HelidonInvocationContext(request, response));
55+
} catch (IOException e) {
56+
reportServerFailure(response, e);
57+
}
7058
}
7159

7260
void reportServerFailure(ServerResponse response, IOException e) {
@@ -76,7 +64,7 @@ void reportServerFailure(ServerResponse response, IOException e) {
7664
abstract void invoke(InvocationContext context) throws IOException;
7765
}
7866

79-
class AuthenticatedHandler extends Handler {
67+
class AuthenticatedHandler extends MyHandler {
8068
private final BiFunction<WebClientFactory, InvocationContext, AuthenticatedCall> builder;
8169

8270
AuthenticatedHandler(BiFunction<WebClientFactory, InvocationContext, AuthenticatedCall> builder) {
@@ -89,7 +77,7 @@ void invoke(InvocationContext context) throws IOException {
8977
}
9078
}
9179

92-
class MainHandler extends Handler {
80+
class MainHandler extends MyHandler {
9381
void invoke(InvocationContext context) throws IOException {
9482
ConfigurationDisplay.displayConfiguration(context.getResponseStream());
9583
context.close();

wls-exporter-sidecar/src/main/resources/logging.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# For more information see $JAVA_HOME/jre/lib/logging.properties
1919

2020
## Send messages to the console
21-
handlers=io.helidon.common.HelidonConsoleHandler
21+
handlers=io.helidon.logging.jul.HelidonConsoleHandler
2222
#
2323
## HelidonConsoleHandler uses a SimpleFormatter subclass that replaces "!thread!" with the current thread
2424
java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n

0 commit comments

Comments
 (0)