Skip to content

Commit 7f758ac

Browse files
authored
Updates to Helidon Common, Part 1 (helidon-io#4693)
* Switch to System.Logger for common modules (except for reactive) * Move HelidonServiceLoader to common module. * GenericType now contains constant for String * Typo fix (Builder) * Using Weight instead of Priority in SE
1 parent 0c796d1 commit 7f758ac

175 files changed

Lines changed: 817 additions & 801 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,10 @@ We are pleased to announce Helidon 4.0.0 a major release that includes significa
1717

1818
### Notable Changes
1919

20-
- Java 19 (with Loom support) as the minimal Java version
20+
- Java 19 early access (with Loom support) as the minimal Java version
21+
- Using System.Logger instead of java util logging (incremental change)
22+
- `HelidonServiceLoader` is now part of `helidon-common` module
23+
- Introduction of `@Weight`, `Weighted` and `Weights` instead of `@Priority` and `Prioritized`, to base ordering on a double (allows to fit a component between any other two components), all modules using priority are refactored (except for MicroProfile where required by specifications).
24+
- higher weight means a component is more important
25+
- moved priority related types to MP config (as that is the lowest level MP module)
26+
- replaces all instances in SE that use priority with weight (no dependency on Jakarta, predictible and easy to understand behavior)

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ Helidon supports two programming models:
2323

2424
In either case your application is just a Java SE program.
2525

26+
## Early access branch
27+
This branch requires Java 19 early access release with Loom support.
28+
Applications written using this version will require `--enable-preview` to be used when starting JVM.
29+
Kindly use latest official release to work with Java 17, unless you are interested in the newest and greatest!
30+
2631
## License
2732

2833
Helidon is available under Apache License 2.0.

bom/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -606,11 +606,6 @@
606606
<artifactId>helidon-common-key-util</artifactId>
607607
<version>${helidon.version}</version>
608608
</dependency>
609-
<dependency>
610-
<groupId>io.helidon.common</groupId>
611-
<artifactId>helidon-common-service-loader</artifactId>
612-
<version>${helidon.version}</version>
613-
</dependency>
614609
<dependency>
615610
<groupId>io.helidon.common</groupId>
616611
<artifactId>helidon-common-media-type</artifactId>

common/common/pom.xml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@
2828
<artifactId>helidon-common</artifactId>
2929
<name>Helidon Common</name>
3030

31+
<properties>
32+
<!-- Helidon common should be backward compatible with Java 11 -->
33+
<version.java>11</version.java>
34+
</properties>
35+
36+
<dependencies>
37+
<dependency>
38+
<groupId>org.junit.jupiter</groupId>
39+
<artifactId>junit-jupiter-api</artifactId>
40+
<scope>test</scope>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.hamcrest</groupId>
44+
<artifactId>hamcrest-all</artifactId>
45+
<scope>test</scope>
46+
</dependency>
47+
</dependencies>
48+
3149
<build>
3250
<plugins>
3351
<plugin>
@@ -71,17 +89,4 @@
7189
</plugin>
7290
</plugins>
7391
</build>
74-
75-
<dependencies>
76-
<dependency>
77-
<groupId>org.junit.jupiter</groupId>
78-
<artifactId>junit-jupiter-api</artifactId>
79-
<scope>test</scope>
80-
</dependency>
81-
<dependency>
82-
<groupId>org.hamcrest</groupId>
83-
<artifactId>hamcrest-all</artifactId>
84-
<scope>test</scope>
85-
</dependency>
86-
</dependencies>
8792
</project>

common/common/src/main/java/io/helidon/common/Builder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2021 Oracle and/or its affiliates.
2+
* Copyright (c) 2017, 2022 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.
@@ -39,7 +39,7 @@ public interface Builder<B extends Builder<B, T>, T> extends Supplier<T> {
3939
T build();
4040

4141
/**
42-
* Update the builder in a fluen API way.
42+
* Update the builder in a fluent API way.
4343
*
4444
* @param consumer consumer of the builder instance
4545
* @return updated builder instance

common/common/src/main/java/io/helidon/common/Errors.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2021 Oracle and/or its affiliates.
2+
* Copyright (c) 2017, 2022 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.
@@ -20,7 +20,6 @@
2020
import java.util.List;
2121
import java.util.Objects;
2222
import java.util.Set;
23-
import java.util.logging.Logger;
2423
import java.util.stream.Collectors;
2524

2625
/**
@@ -115,7 +114,7 @@ public boolean hasHint() {
115114
* otherwise.
116115
*/
117116

118-
public boolean log(Logger logger) {
117+
public boolean log(System.Logger logger) {
119118
if (!isEmpty()) {
120119
StringBuilder fatals = new StringBuilder("\n");
121120
StringBuilder warnings = new StringBuilder();
@@ -141,14 +140,14 @@ public boolean log(Logger logger) {
141140
if (hasFatal) {
142141
fatals.append(warnings).append(hints);
143142

144-
logger.severe("Fatal issues found: " + fatals);
143+
logger.log(System.Logger.Level.ERROR, "Fatal issues found: " + fatals);
145144
} else {
146145
if (warnings.length() > 0) {
147-
logger.warning("Warnings found: \n" + warnings);
146+
logger.log(System.Logger.Level.WARNING, "Warnings found: \n" + warnings);
148147
}
149148

150149
if (hints.length() > 0) {
151-
logger.config("Hints found: \n" + hints);
150+
logger.log(System.Logger.Level.TRACE, "Hints found: \n" + hints);
152151
}
153152
}
154153

common/common/src/main/java/io/helidon/common/GenericType.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021 Oracle and/or its affiliates.
2+
* Copyright (c) 2018, 2022 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.
@@ -62,6 +62,11 @@
6262
* @param <T> the generic type parameter
6363
*/
6464
public class GenericType<T> implements Type {
65+
/**
66+
* Generic type for String.
67+
*/
68+
public static final GenericType<String> STRING = GenericType.create(String.class);
69+
6570
private final Type type;
6671
private final Class<?> rawType;
6772

common/common/src/main/java/io/helidon/common/HelidonFeatures.java

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2022 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.
@@ -16,6 +16,7 @@
1616

1717
package io.helidon.common;
1818

19+
import java.lang.System.Logger.Level;
1920
import java.util.Comparator;
2021
import java.util.EnumMap;
2122
import java.util.HashMap;
@@ -28,7 +29,6 @@
2829
import java.util.TreeSet;
2930
import java.util.concurrent.atomic.AtomicBoolean;
3031
import java.util.concurrent.atomic.AtomicReference;
31-
import java.util.logging.Logger;
3232
import java.util.stream.Collectors;
3333

3434
/**
@@ -56,8 +56,8 @@
5656
* </pre>
5757
*/
5858
public final class HelidonFeatures {
59-
private static final Logger LOGGER = Logger.getLogger(HelidonFeatures.class.getName());
60-
private static final Logger EXPERIMENTAL = Logger.getLogger(HelidonFeatures.class.getName() + ".experimental");
59+
private static final System.Logger LOGGER = System.getLogger(HelidonFeatures.class.getName());
60+
private static final System.Logger EXPERIMENTAL = System.getLogger(HelidonFeatures.class.getName() + ".experimental");
6161
private static final AtomicBoolean PRINTED = new AtomicBoolean();
6262
private static final AtomicBoolean SCANNED = new AtomicBoolean();
6363
private static final AtomicReference<HelidonFlavor> CURRENT_FLAVOR = new AtomicReference<>();
@@ -145,16 +145,16 @@ private static void features(HelidonFlavor flavor, String version, boolean detai
145145

146146
Set<FeatureDescriptor> features = FEATURES.get(currentFlavor);
147147
if (null == features) {
148-
LOGGER.info("Helidon " + currentFlavor + " " + version + " has no registered features");
148+
LOGGER.log(Level.INFO, "Helidon " + currentFlavor + " " + version + " has no registered features");
149149
} else {
150150
String featureString = "[" + features.stream()
151151
.map(FeatureDescriptor::name)
152152
.collect(Collectors.joining(", "))
153153
+ "]";
154-
LOGGER.info("Helidon " + currentFlavor + " " + version + " features: " + featureString);
154+
LOGGER.log(Level.INFO, "Helidon " + currentFlavor + " " + version + " features: " + featureString);
155155
}
156156
if (details) {
157-
LOGGER.info("Detailed feature tree:");
157+
LOGGER.log(Level.INFO, "Detailed feature tree:");
158158
FEATURES.get(currentFlavor)
159159
.forEach(feature -> printDetails(feature.name(),
160160
ROOT_FEATURE_NODES.get(currentFlavor).get(feature.path()[0]),
@@ -166,9 +166,11 @@ private static void features(HelidonFlavor flavor, String version, boolean detai
166166
ROOT_FEATURE_NODES.get(currentFlavor).get(feature.path()[0])));
167167

168168
if (!allExperimental.isEmpty()) {
169-
EXPERIMENTAL.info("You are using experimental features. These APIs may change, please follow changelog!");
169+
EXPERIMENTAL.log(Level.INFO,
170+
"You are using experimental features. These APIs may change, please follow changelog!");
170171
allExperimental
171-
.forEach(it -> EXPERIMENTAL.info("\tExperimental feature: " + it.name() + " (" + it.stringPath() + ")"));
172+
.forEach(it -> EXPERIMENTAL.log(Level.INFO,
173+
"\tExperimental feature: " + it.name() + " (" + it.stringPath() + ")"));
172174
}
173175
}
174176
}
@@ -184,20 +186,21 @@ private static void gatherExperimental(List<FeatureDescriptor> allExperimental,
184186
* Will scan all features and log errors and warnings for features that have a
185187
* native image limitation.
186188
* This method is automatically called when building a native image with Helidon.
189+
*
187190
* @param classLoader to look for features in
188191
*/
189192
public static void nativeBuildTime(ClassLoader classLoader) {
190193
scan(classLoader);
191194
for (FeatureDescriptor feat : ALL_FEATURES) {
192195
if (!feat.nativeSupported()) {
193-
LOGGER.severe("Feature '" + feat.name()
194-
+ "' for path '" + feat.stringPath()
195-
+ "' IS NOT SUPPORTED in native image. Image may still build and run.");
196+
LOGGER.log(Level.ERROR, "Feature '" + feat.name()
197+
+ "' for path '" + feat.stringPath()
198+
+ "' IS NOT SUPPORTED in native image. Image may still build and run.");
196199
} else {
197200
if (!feat.nativeDescription().isBlank()) {
198-
LOGGER.warning("Feature '" + feat.name()
199-
+ "' for path '" + feat.stringPath()
200-
+ "' has limited support in native image: " + feat.nativeDescription());
201+
LOGGER.log(Level.WARNING, "Feature '" + feat.name()
202+
+ "' for path '" + feat.stringPath()
203+
+ "' has limited support in native image: " + feat.nativeDescription());
201204
}
202205
}
203206
}
@@ -230,7 +233,7 @@ private static void scan(ClassLoader classLoader) {
230233
Set<FeatureDescriptor> featureDescriptors = FeatureCatalog.get(packageName);
231234
if (featureDescriptors == null) {
232235
if (packageName.startsWith("io.helidon.")) {
233-
LOGGER.fine("No catalog entry for package " + packageName);
236+
LOGGER.log(Level.TRACE, "No catalog entry for package " + packageName);
234237
}
235238
} else {
236239
featureDescriptors.forEach(HelidonFeatures::register);
@@ -244,15 +247,15 @@ private static void scan(ClassLoader classLoader) {
244247
if (feature.nativeSupported()) {
245248
String desc = feature.nativeDescription();
246249
if (desc != null && !desc.isBlank()) {
247-
LOGGER.warning("Native image for feature "
250+
LOGGER.log(Level.WARNING, "Native image for feature "
248251
+ feature.name()
249252
+ "("
250253
+ feature.stringPath()
251254
+ "): "
252255
+ desc);
253256
}
254257
} else {
255-
LOGGER.severe("You are using a feature not supported in native image: "
258+
LOGGER.log(Level.ERROR, "You are using a feature not supported in native image: "
256259
+ feature.name()
257260
+ "("
258261
+ feature.stringPath()

0 commit comments

Comments
 (0)