-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from liweinan/resteasy-glow
add a blog post: Using WildFly Glow to provision a WildFly server for a RESTEasy based project
- Loading branch information
Showing
1 changed file
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
--- | ||
layout: post | ||
title: "Using WildFly Glow to provision a WildFly server for a RESTEasy based project" | ||
subtitle: "" | ||
date: 2024-01-31 | ||
author: Wei Nan Li | ||
--- | ||
|
||
Recently I created a sample project showing the usage of the feature for deploying a RESTEasy based sample project[^sample-project]. The project contains a minimal REST based service and a test case, and it uses the `maven-wildfly-plugin` to produce a provisioned WildFly server for the integration testing. | ||
|
||
The `maven-wildfly-plugin` has integrated WildFly Glow[^glow] since `5.0.0.Alpha1`[^glow-integration]. I have created the PR to the sample project to enable the feature[^enable-glow]. | ||
|
||
I’ll give some brief description to the above configuration. To use the Glow feature, first we need to add the following configuration to the `wildfly-maven-plugin`: | ||
|
||
```xml | ||
<discover-provisioning-info> | ||
<version>${version.wildfly}</version> | ||
<failsOnError>false</failsOnError> | ||
</discover-provisioning-info> | ||
``` | ||
|
||
The above `discover-provisioning-info` will enable the embedded Glow feature to scan the project source code and detect the layers to be used in the provisioned WildFly server. Next in the `executions` section of the plugin, the `package` goal needs to be added: | ||
|
||
```xml | ||
<execution> | ||
<id>wildfly-glow-provision</id> | ||
<goals> | ||
<goal>package</goal> | ||
</goals> | ||
</execution> | ||
``` | ||
|
||
To start the provisioned WildFly server and deploy the sample project before the integration testings and shutdown the server after the testings, add the following execution configuration: | ||
|
||
```xml | ||
<execution> | ||
<id>wildfly-start</id> | ||
<phase>pre-integration-test</phase> | ||
<goals> | ||
<goal>start</goal> | ||
<goal>deploy</goal> | ||
</goals> | ||
<configuration> | ||
<filename>resteasy-wildfly.war</filename> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<phase>post-integration-test</phase> | ||
<id>wildfly-stop</id> | ||
<goals> | ||
<goal>shutdown</goal> | ||
</goals> | ||
</execution> | ||
``` | ||
|
||
In addition, if we need to separate the integration tests from the ordinary tests, we can configure these two plugins: | ||
|
||
```xml | ||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<configuration> | ||
<testClassesDirectory>${project.build.testOutputDirectory}</testClassesDirectory> | ||
<includes> | ||
<include>**/*IT.java</include> | ||
</includes> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
``` | ||
|
||
The above setup will run the integration tests that has the name pattern `**/*IT.java` and execute the tests during the `integration-test` and `verify` phases. After explaining the meaning of the configurations, you can run the project with the following command: | ||
|
||
```bash | ||
$ mvn verify | ||
``` | ||
|
||
The above command will run the `pre-integration-test`, `integration-test` and the `post-integration-test` phases. Here is part of the output generated by the above command related with Glow: | ||
|
||
``` | ||
... | ||
[INFO] Glow is scanning... | ||
[INFO] Glow scanning DONE. | ||
[INFO] context: bare-metal | ||
[INFO] enabled profile: none | ||
[INFO] galleon discovery | ||
[INFO] - feature-packs | ||
org.wildfly:wildfly-galleon-pack:30.0.1.Final | ||
- layers | ||
ee-core-profile-server | ||
jaxrs | ||
[INFO] Some suggestions have been found. You could enable suggestions with the --suggest option (if using the WildFly Glow CLI) or <suggest>true</suggest> (if using the WildFly Maven Plugin). | ||
[INFO] Provisioning server in /Users/weli/works/resteasy-wildfly/target/server | ||
[INFO] Resolving feature-packs | ||
[INFO] Installing packages | ||
[INFO] Resolving artifacts | ||
[INFO] Generating configurations | ||
... | ||
``` | ||
|
||
From the above output we can see that the `jaxrs` layer is detected automatically by the Glow scanning feature. The layer is detected by scanning the source code of the sample project, and it found the Jakarta REST annotations in the source code, so the `jaxrs` layer is added in the provisioned server. Then the provisioned server will be started, and the integration tests will be run in the server, and finally the server will be stopped after the integration testing phase. | ||
|
||
Above is the brief usage of the Glow feature to automate the server provision process. | ||
|
||
## References | ||
|
||
[^glow]: [https://www.wildfly.org/news/2024/01/29/wildfly-glow/](https://www.wildfly.org/news/2024/01/29/wildfly-glow/) | ||
[^sample-project]: [https://github.com/liweinan/resteasy-wildfly](https://github.com/liweinan/resteasy-wildfly) | ||
[^glow-integration]: [https://github.com/wildfly/wildfly-maven-plugin/pull/374](https://github.com/wildfly/wildfly-maven-plugin/pull/374) | ||
[^enable-glow]: [resteasy-wildfly / Use Glow #6](https://github.com/liweinan/resteasy-wildfly/pull/6) | ||
|
||
|