Skip to content

Commit

Permalink
Merge branch 'current' into issue-4191
Browse files Browse the repository at this point in the history
  • Loading branch information
mnriem authored Nov 20, 2024
2 parents 1bce957 + f5c4f67 commit f49b80d
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 81 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
java-version: 21
- name: Build with Maven
run: |
mvn -B -DskipTests -DskipITs -ntp -T 1 install site
mvn -B -DskipTests -DskipITs -DstagingDirectory=$PWD/target/staging -ntp -T 1 install site site:stage
rm -rf piranha-website/snapshot || true
mkdir -p piranha-website/snapshot || true
cp -R target/site/* piranha-website/snapshot/
cp -R target/staging/* piranha-website/snapshot/
cd piranha-website
git config --global user.email "[email protected]"
git config --global user.name "Automated publish"
Expand Down
2 changes: 2 additions & 0 deletions dist/coreprofile/src/site/site.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<body>
<menu name="Core Profile">
<item name="Introduction" href="index.html"/>
</menu>
<menu name="Guides">
<item name="Create a REST service" href="create_a_rest_service.html"/>
<item name="Create a JSON REST service" href="create_a_json_rest_service.html"/>
<item name="Debugging a REST service with NetBeans" href="debugging_a_rest_service_with_netbeans.html"/>
Expand Down
15 changes: 10 additions & 5 deletions extension/scinitializer/pom.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>cloud.piranha.extension</groupId>
<artifactId>project</artifactId>
<version>24.12.0-SNAPSHOT</version>
</parent>

<artifactId>piranha-extension-scinitializer</artifactId>
<packaging>jar</packaging>

<name>Piranha - Extension - ServletContainerInitializer</name>

<dependencies>
<!-- compile -->
<dependency>
Expand All @@ -40,4 +39,10 @@
<scope>test</scope>
</dependency>
</dependencies>
<distributionManagement>
<site>
<id>default</id>
<url>file:///tmp/piranha/extension/scinitializer</url>
</site>
</distributionManagement>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class ServletContainerInitializerExtension implements WebApplicationExten
* Stores the exclude existing initializers flag.
*/
private final boolean excludeExistingInitializers;

/**
* Stores the initializers to be ignored.
*/
Expand All @@ -73,8 +73,9 @@ public ServletContainerInitializerExtension() {

/**
* Constructor.
*
* @param excludeExistingInitializers the exclude existing initializers flag.
*
* @param excludeExistingInitializers the exclude existing initializers
* flag.
* @param ignoreInitializers ignore the given initializers.
*/
public ServletContainerInitializerExtension(boolean excludeExistingInitializers, List<String> ignoreInitializers) {
Expand All @@ -89,33 +90,37 @@ public ServletContainerInitializerExtension(boolean excludeExistingInitializers,
*/
@Override
public void configure(WebApplication webApplication) {
LOGGER.log(DEBUG, "Starting ServletContainerInitializer processing");
ServiceLoader<ServletContainerInitializer> serviceLoader = ServiceLoader.load(
ServletContainerInitializer.class, webApplication.getClassLoader());
LOGGER.log(TRACE, "Configuring the ServletContainerInitializer extension");

for (ServletContainerInitializer initializer : serviceLoader) {
LOGGER.log(DEBUG, () -> "Adding initializer: " + initializer.getClass().getName());
if (Boolean.parseBoolean(System.getProperty(
"cloud.piranha.extension.scinitializer.ServletContainerInitializerExtensionp.enabled",
"true"))) {

if (shouldAdd(webApplication, initializer)) {
webApplication.addInitializer(initializer);
}
}
ServiceLoader<ServletContainerInitializer> serviceLoader = ServiceLoader.load(
ServletContainerInitializer.class, webApplication.getClassLoader());

if (getClass().getModule().isNamed()) {
// We are running in a modular environment,
// the providers from modules aren't available in the webApplication classloader
serviceLoader = ServiceLoader.load(ServletContainerInitializer.class);

for (ServletContainerInitializer initializer : serviceLoader) {
LOGGER.log(DEBUG, () -> "Adding initializer: " + initializer.getClass().getName());

if (shouldAdd(webApplication, initializer)) {
webApplication.addInitializer(initializer);
}
}

if (getClass().getModule().isNamed()) {
// We are running in a modular environment,
// the providers from modules aren't available in the webApplication classloader
serviceLoader = ServiceLoader.load(ServletContainerInitializer.class);

for (ServletContainerInitializer initializer : serviceLoader) {
LOGGER.log(DEBUG, () -> "Adding initializer: " + initializer.getClass().getName());

if (shouldAdd(webApplication, initializer)) {
webApplication.addInitializer(initializer);
}
}
}
}

LOGGER.log(TRACE, "Finished ServletContainerInitializer processing");
}

private boolean shouldAdd(WebApplication webApplication, ServletContainerInitializer initializer) {
Expand All @@ -132,15 +137,13 @@ private boolean shouldAdd(WebApplication webApplication, ServletContainerInitial

private boolean containsInstance(WebApplication webApplication, ServletContainerInitializer initializer) {
return webApplication.getInitializers()
.stream()
.anyMatch(e -> e.getClass().equals(initializer.getClass()));
.stream()
.anyMatch(e -> e.getClass().equals(initializer.getClass()));
}

private boolean isIgnored(ServletContainerInitializer initializer) {
return ignoreInitializers
.stream()
.anyMatch(e -> e.equals(initializer.getClass().getName()));
.stream()
.anyMatch(e -> e.equals(initializer.getClass().getName()));
}


}
16 changes: 16 additions & 0 deletions extension/scinitializer/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@
/**
* This module delivers the ServletContainerInitializer extension.
*
*
* <p>
* The following property can be used to influence the workings of this module.
* </p>
* <table>
* <tr>
* <th>Property</th>
* <th>Notes</th>
* </tr>
* <tr>
* <td>cloud.piranha.extension.scinitializer.ServletContainerInitializerExtension.enabled</td>
* <td>true to enable (default), false to disable</td>
* </tr>
* <caption>Configurable properties</caption>
* </table>
*
* @author Manfred Riem ([email protected])
*/
module cloud.piranha.extension.scinitializer {
Expand Down
46 changes: 5 additions & 41 deletions extension/tempdir/pom.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cloud.piranha.extension</groupId>
<artifactId>project</artifactId>
<version>24.12.0-SNAPSHOT</version>
</parent>

<artifactId>piranha-extension-tempdir</artifactId>
<packaging>jar</packaging>

<name>Piranha - Extension - TEMPDIR</name>

<dependencies>
<!-- compile -->
<dependency>
Expand All @@ -39,40 +39,4 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>0.80</minimum>
</limit>
<limit>
<counter>CLASS</counter>
<value>MISSEDCOUNT</value>
<maximum>0</maximum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
10 changes: 5 additions & 5 deletions src/site/markdown/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ distribution supports see our [Jakarta EE / Micro Profile matrix](https://piranh

## Distribution specific documentation

* [Piranha Core Profile](coreprofile/index.html)
* [Piranha Embedded](embedded/index.html)
* [Piranha Servlet](servlet/index.html)
* [Piranha Server](server/index.html)
* [Piranha Web Profile](webprofile/index.html)
* [Piranha Core Profile](dist/coreprofile/index.html)
* [Piranha Embedded](dist/embedded/index.html)
* [Piranha Servlet](dist/servlet/index.html)
* [Piranha Server](dist/server/index.html)
* [Piranha Web Profile](dist/webprofile/index.html)

## Maven Plugin documentation

Expand Down
4 changes: 1 addition & 3 deletions src/site/site.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@
</links>
<menu inherit="top" name="Overview">
<item name="Getting Started" href="index.html"/>
<item name="Maven Plugin" href="maven/plugin/index.html"/>
</menu>
<menu name="Distributions">
<item name="Core Profile" href="dist/coreprofile/index.html" />
<item name="Embedded" href="embedded/index.html" />
</menu>
<menu inherit="bottom" name="Maven">
<item name="Plugin" href="maven/plugin/index.html"/>
</menu>
<menu name="Piranha Micro">
<item name="Overview" href="micro/index.html"/>
<item name="Guides">
Expand Down

0 comments on commit f49b80d

Please sign in to comment.