Skip to content

Commit 76b8fbe

Browse files
committed
Helidon MP revamped for native-image
Signed-off-by: Tomas Langer <tomas.langer@oracle.com> Work around issues with the reduced pom created by maven-shade-plugin. See https://issues.apache.org/jira/browse/MNG-5899 Inline the reduced dependencies in the original pom. Turn-off reduced pom generation. Update microprofile/weld/pom.xml Build fixes after repackaging weld. Build fix - spotbugs exclude missing. Simplify build and runtime events. Using predefined priorities. Validations for all modules in test. Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
1 parent feeeb8c commit 76b8fbe

396 files changed

Lines changed: 9630 additions & 14383 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: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,6 @@ All notable changes to this project will be documented in this file.
55

66
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## 2.0.0
9-
### Backward incompatible changes
10-
#### Common
11-
- Removed `io.helidon.reactive.Flow`, please use `java.util.concurrent.Flow`
12-
- Removed `io.helidon.common.CollectionsHelper`, please use factory methods of `Set`, `Map` and `List`
13-
- Removed `io.helidon.common.OptionalHelper`, please use methods of `java.util.Optional`
14-
- Removed `io.helidon.common.StackWalker`, please use `java.lang.StackWalker`
15-
- Removed `io.helidon.common.InputStreamHelper`, please use `java.io.InputStream` methods
16-
17-
#### Tracing
18-
- We have upgraded to OpenTracing version 0.33.0 that is not backward compatible, the following breaking changes exist
19-
(these are OpenTracing changes, not Helidon changes):
20-
1. `TextMapExtractAdapter` and `TextMapInjectAdapter` are now `TextMapAdapter`
21-
2. module name changed from `opentracing.api` to `io.opentracing.api` (same for `noop` and `util`)
22-
3. `SpanBuilder` no longer has `startActive` method, you need to use `Tracer.activateSpan(Span)`
23-
4. `ScopeManager.activate(Span, boolean)` is replaced by `ScopeManager.activate(Span)` - second parameter is now always
24-
`false`
25-
5. `Scope ScopeManager.active()` is removed - replaced by `Span Tracer.activeSpan()`
26-
- If you use the `TracerBuilder` abstraction in Helidon and have no custom Spans, there is no change required
27-
288
## [1.4.0]
299

3010
### Notes

CHANGELOG_2.0.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
2+
# Changelog of Helidon 2.x
3+
4+
All notable changes to this project will be documented in this file.
5+
6+
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Notes
11+
12+
This is a major release of Helidon.
13+
14+
### Backward incompatible changes
15+
16+
#### Common
17+
- Removed `io.helidon.reactive.Flow`, please use `java.util.concurrent.Flow`
18+
- Removed `io.helidon.common.CollectionsHelper`, please use factory methods of `Set`, `Map` and `List`
19+
- Removed `io.helidon.common.OptionalHelper`, please use methods of `java.util.Optional`
20+
- Removed `io.helidon.common.StackWalker`, please use `java.lang.StackWalker`
21+
- Removed `io.helidon.common.InputStreamHelper`, please use `java.io.InputStream` methods
22+
23+
#### Tracing
24+
- We have upgraded to OpenTracing version 0.33.0 that is not backward compatible, the following breaking changes exist
25+
(these are OpenTracing changes, not Helidon changes):
26+
1. `TextMapExtractAdapter` and `TextMapInjectAdapter` are now `TextMapAdapter`
27+
2. module name changed from `opentracing.api` to `io.opentracing.api` (same for `noop` and `util`)
28+
3. `SpanBuilder` no longer has `startActive` method, you need to use `Tracer.activateSpan(Span)`
29+
4. `ScopeManager.activate(Span, boolean)` is replaced by `ScopeManager.activate(Span)` - second parameter is now always
30+
`false`
31+
5. `Scope ScopeManager.active()` is removed - replaced by `Span Tracer.activeSpan()`
32+
- If you use the `TracerBuilder` abstraction in Helidon and have no custom Spans, there is no change required
33+
34+
#### Config
35+
Meta configuration has been refactored to be done through `ServiceLoader` services. If you created
36+
a custom `ConfigSource`, `PollingStrategy` or `RetryPolicy`, please have a look at the new documentation.
37+
38+
Config now implements MicroProfile config (not explicitly, you can cast between MP Config and Helidon Config).
39+
There is a very small behavior change between MP methods and SE methods of config related to system
40+
property handling:
41+
42+
The MP TCK require that system properties are fully mutable (e.g. as soon as the property is changed, it
43+
must be used), so MP Config methods work in this manner (with a certain performance overhead).
44+
Helidon Config treats System properties as a mutable config source, with a time based polling strategy. So
45+
the change is reflected as well, though not immediately (this is only relevant if you use change notifications).
46+
47+
#### Metrics
48+
Helidon now supports only MicroProfile Metrics 2.x. Modules for Metrics 1.x were removed, and
49+
modules for 2.x were renamed from `metrics2` to `metrics`.
50+
51+
52+
#### Microprofile Bundles
53+
We have removed all versioned MP bundles.
54+
You can use the following:
55+
56+
- `io.helidon.microprofile.bundles:helidon-microprofile-core` - contains MP Server and Config, allows you to add only
57+
specifications needed by your application
58+
- `io.helidon.microprofile.bundles:helidon-microprofile` - contains the latest MP version implemented by Helidon
59+
60+
#### Helidon CDI and MicroProfile Server
61+
62+
- You cannot start CDI container yourself (this change is required so we can
63+
support GraalVM `native-image`)
64+
- You can only run a single instance of Server in a JVM
65+
- If you use `SeContainerInitializer` you would get an exception
66+
- this can be worked around by configuration property `mp.initializer.allow=true`, and warning can be removed
67+
using `mp.initializer.no-warn=true`
68+
- once `SeContainerInitializer` is used, you can no longer use MP with `native-image`
69+
- You can no longer provide a `Context` instance, root context is now built-in
70+
- `MpService` and `MpServiceContext` have been removed
71+
- methods from context have been moved to `JaxRsCdiExtension` and `ServerCdiExtension` that can be accessed
72+
from CDI extension through `BeanManager.getExtension`.
73+
- methods `register` can be used on current `io.helidon.context.Context`
74+
- `MpService` equivalent is a CDI extension. All Helidon services were refactored to CDI extension
75+
(you can use these for reference)
76+
- `Server.cdiContainer` is removed, use `CDI.current()` instead
77+
78+
#### Startup
79+
New recommended option to start Helidon MP:
80+
1. Use class `io.helidon.microprofile.cdi.Main`
81+
2. Use meta configuration option when advanced configuration of config is required (e.g. `meta-config.yaml`)
82+
3. Put `logging.properties` on the classpath or in the current directory to be automatically picked up to configure
83+
Java util logging
84+
85+
`io.helidon.microprofile.server.Main` is still available, just calls `io.helidon.microprofile.cdi.Main` and is deprecated.
86+
`io.helidon.microprofile.server.Server` is still available, though the features are much reduced
87+
88+
89+
### Improvements
90+
91+
- JAX-RS applications now work similar to how they work in application servers
92+
- if there is an `Application` subclass that returns anything from `getClasses` or `getSingletons`, it is used as is
93+
- if there is an `Application` subclass that returns empty sets from these methods, all available resource classes will be
94+
part of such an application
95+
- if there is no `Application` subclass, a synthetic application will be created with all available resource classes
96+
- `Application` subclasses MUST be annotated with `@ApplicationScoped`, otherwise they are ignored
97+
98+
### Fixes
99+
100+
### Deprecations
101+
102+
## Experimental
103+
104+
The following enhancements are experimental. They should be considered unstable and subject
105+
to change.
106+
107+
## Thanks!

applications/mp/pom.xml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
4+
Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@
3333
<properties>
3434
<version.plugin.jandex>1.0.6</version.plugin.jandex>
3535
<version.plugin.eclipselink>2.7.1.1</version.plugin.eclipselink>
36-
<mainClass>io.helidon.microprofile.server.Main</mainClass>
36+
<mainClass>io.helidon.microprofile.cdi.Main</mainClass>
3737
</properties>
3838

3939
<build>
@@ -73,4 +73,31 @@
7373
</plugins>
7474
</pluginManagement>
7575
</build>
76+
77+
<profiles>
78+
<profile>
79+
<id>native-image</id>
80+
<build>
81+
<plugins>
82+
<plugin>
83+
<groupId>io.helidon.build-tools</groupId>
84+
<artifactId>helidon-maven-plugin</artifactId>
85+
<executions>
86+
<execution>
87+
<goals>
88+
<goal>native-image</goal>
89+
</goals>
90+
</execution>
91+
</executions>
92+
</plugin>
93+
</plugins>
94+
</build>
95+
<dependencies>
96+
<dependency>
97+
<groupId>io.helidon.integrations.graal</groupId>
98+
<artifactId>helidon-mp-graal-native-image-extension</artifactId>
99+
</dependency>
100+
</dependencies>
101+
</profile>
102+
</profiles>
76103
</project>

archetypes/se/src/main/resources/archetype-resources/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#if( $metricsSupport.matches("y|yes|true") )
5050
<dependency>
5151
<groupId>io.helidon.metrics</groupId>
52-
<artifactId>helidon-metrics2</artifactId>
52+
<artifactId>helidon-metrics</artifactId>
5353
</dependency>
5454
#end
5555
#if( $unitTest.matches("y|yes|true") )

bom/pom.xml

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved.
4+
Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved.
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.
@@ -356,31 +356,6 @@
356356
<version>${helidon.version}</version>
357357
</dependency>
358358
<!-- microprofile -->
359-
<dependency>
360-
<groupId>io.helidon.microprofile.bundles</groupId>
361-
<artifactId>helidon-microprofile-1.1</artifactId>
362-
<version>${helidon.version}</version>
363-
</dependency>
364-
<dependency>
365-
<groupId>io.helidon.microprofile.bundles</groupId>
366-
<artifactId>helidon-microprofile-1.2</artifactId>
367-
<version>${helidon.version}</version>
368-
</dependency>
369-
<dependency>
370-
<groupId>io.helidon.microprofile.bundles</groupId>
371-
<artifactId>helidon-microprofile-2.2</artifactId>
372-
<version>${helidon.version}</version>
373-
</dependency>
374-
<dependency>
375-
<groupId>io.helidon.microprofile.bundles</groupId>
376-
<artifactId>helidon-microprofile-3.0</artifactId>
377-
<version>${helidon.version}</version>
378-
</dependency>
379-
<dependency>
380-
<groupId>io.helidon.microprofile.bundles</groupId>
381-
<artifactId>helidon-microprofile-3.1</artifactId>
382-
<version>${helidon.version}</version>
383-
</dependency>
384359
<dependency>
385360
<groupId>io.helidon.microprofile.bundles</groupId>
386361
<artifactId>helidon-microprofile-core</artifactId>
@@ -412,8 +387,13 @@
412387
<version>${helidon.version}</version>
413388
</dependency>
414389
<dependency>
415-
<groupId>io.helidon.microprofile.metrics</groupId>
416-
<artifactId>helidon-microprofile-metrics2</artifactId>
390+
<groupId>io.helidon.microprofile</groupId>
391+
<artifactId>weld-se-core</artifactId>
392+
<version>${helidon.version}</version>
393+
</dependency>
394+
<dependency>
395+
<groupId>io.helidon.microprofile.cdi</groupId>
396+
<artifactId>helidon-microprofile-cdi</artifactId>
417397
<version>${helidon.version}</version>
418398
</dependency>
419399
<dependency>
@@ -447,11 +427,7 @@
447427
<artifactId>helidon-metrics</artifactId>
448428
<version>${helidon.version}</version>
449429
</dependency>
450-
<dependency>
451-
<groupId>io.helidon.metrics</groupId>
452-
<artifactId>helidon-metrics2</artifactId>
453-
<version>${helidon.version}</version>
454-
</dependency>
430+
455431
<!-- health checks -->
456432
<dependency>
457433
<groupId>io.helidon.health</groupId>
@@ -705,6 +681,11 @@
705681
<artifactId>helidon-graal-native-image-extension</artifactId>
706682
<version>${helidon.version}</version>
707683
</dependency>
684+
<dependency>
685+
<groupId>io.helidon.integrations.graal</groupId>
686+
<artifactId>helidon-mp-graal-native-image-extension</artifactId>
687+
<version>${helidon.version}</version>
688+
</dependency>
708689
<!-- OpenAPI support -->
709690
<dependency>
710691
<groupId>io.helidon.openapi</groupId>
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.helidon.common;
18+
19+
import java.util.EnumMap;
20+
import java.util.HashSet;
21+
import java.util.Map;
22+
import java.util.Set;
23+
import java.util.concurrent.atomic.AtomicBoolean;
24+
import java.util.concurrent.atomic.AtomicReference;
25+
import java.util.logging.Logger;
26+
27+
/**
28+
* A java service loader interface defining a Helidon feature.
29+
*/
30+
public final class HelidonFeatures {
31+
private static final Logger LOGGER = Logger.getLogger(HelidonFeatures.class.getName());
32+
33+
private static final Map<HelidonFlavor, Set<String>> FEATURES = new EnumMap<>(HelidonFlavor.class);
34+
private static final AtomicReference<HelidonFlavor> CURRENT_FLAVOR = new AtomicReference<>();
35+
private static final AtomicBoolean PRINTED = new AtomicBoolean();
36+
37+
private HelidonFeatures() {
38+
}
39+
40+
/**
41+
* Register a feature for a flavor.
42+
* This should be called from a static initializer of a feature
43+
* class. In SE this would be one of the *Support classes or similar,
44+
* in MP most likely a CDI extension class.
45+
*
46+
* @param flavor flavor to register a feature for
47+
* @param name name of the feature
48+
*/
49+
public static void register(HelidonFlavor flavor, String name) {
50+
FEATURES.computeIfAbsent(flavor, key -> new HashSet<>())
51+
.add(name);
52+
}
53+
54+
/**
55+
* Print features for the current flavor.
56+
* If {@link #flavor(HelidonFlavor)} is called, this method
57+
* would only print the list if it matches the flavor provided.
58+
* This is to make sure we do not print SE flavors in MP, and at the
59+
* same time can have this method used from Web Server.
60+
* This method only prints feature the first time it is called.
61+
* @param flavor flavor to print features for
62+
*/
63+
public static void print(HelidonFlavor flavor) {
64+
CURRENT_FLAVOR.compareAndSet(null, HelidonFlavor.SE);
65+
66+
HelidonFlavor currentFlavor = CURRENT_FLAVOR.get();
67+
68+
if (currentFlavor != flavor) {
69+
return;
70+
}
71+
72+
if (PRINTED.compareAndSet(false, true)) {
73+
Set<String> strings = FEATURES.get(currentFlavor);
74+
if (null == strings) {
75+
LOGGER.info("Helidon " + currentFlavor + " " + Version.VERSION + " has no registered features");
76+
} else {
77+
LOGGER.info("Helidon " + currentFlavor + " " + Version.VERSION + " features: " + strings);
78+
}
79+
}
80+
}
81+
82+
/**
83+
* Set the current Helidon flavor. Features will only be printed for the
84+
* flavor configured.
85+
*
86+
* @param flavor current flavor
87+
*/
88+
public static void flavor(HelidonFlavor flavor) {
89+
CURRENT_FLAVOR.compareAndSet(null, flavor);
90+
}
91+
}

microprofile/bundles/helidon-microprofile-1.1/src/main/java/module-info.java renamed to common/common/src/main/java/io/helidon/common/HelidonFlavor.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
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.
@@ -14,10 +14,18 @@
1414
* limitations under the License.
1515
*/
1616

17+
package io.helidon.common;
18+
1719
/**
18-
* Aggregator module for microprofile 1.1.
20+
* Flavors of Helidon.
1921
*/
20-
module io.helidon.microprofile.v1_1 {
21-
requires transitive io.helidon.microprofile.config;
22-
requires transitive io.helidon.microprofile.server;
22+
public enum HelidonFlavor {
23+
/**
24+
* The "standard edition" flavor.
25+
*/
26+
SE,
27+
/**
28+
* The "MicroProfile" flavor.
29+
*/
30+
MP
2331
}

0 commit comments

Comments
 (0)