This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new b809ba400b Change the webapp module (incubator) to a support module
for other web application.
b809ba400b is described below
commit b809ba400bf4f724d381fddb4e8d07a35f106dd9
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Tue Nov 3 15:54:08 2026 +0100
Change the webapp module (incubator) to a support module for other web
application.
---
.../referencing/factory/sql/EPSGFactoryTest.java | 2 +-
.../main/org/apache/sis/system/Shutdown.java | 3 ++-
.../main/org/apache/sis/system/SystemListener.java | 2 +-
incubator/build.gradle.kts | 1 +
.../jakarta.servlet.ServletContainerInitializer | 1 +
.../javax.servlet.ServletContainerInitializer | 1 +
.../org.apache.sis.webapp/main/module-info.java | 20 ++++++++++++---
.../main/org/apache/sis/services/Servlet.java | 26 -------------------
.../org/apache/sis/services/ServletListener.java | 18 +++++++++-----
...letListener.java => ServletListenerLegacy.java} | 29 +++++++++++++---------
.../main/org/apache/sis/services/package-info.java | 2 +-
.../webapp/META-INF/context.xml | 26 -------------------
netbeans-project/ivy.xml | 1 +
13 files changed, 55 insertions(+), 77 deletions(-)
diff --git
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
index bc9f776f42..fbbf9239a4 100644
---
a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
+++
b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
@@ -1025,7 +1025,7 @@ public final class EPSGFactoryTest extends
TestCaseWithLogs {
/**
* Tests {@link EPSGFactory#newIdentifiedObjectFinder()} method in a way
that requires collation support.
- * This test reproduces the * <a
href="https://sis.apache.org/command-line.html#identifier">Getting a verified
+ * This test reproduces the <a
href="https://sis.apache.org/command-line.html#identifier">Getting a verified
* EPSG identifier from a Coordinate Reference System</a> example with
{@code MissingIdentifier.wkt} sample file.
*
* @throws FactoryException if an error occurred while querying the
factory.
diff --git
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Shutdown.java
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Shutdown.java
index 6015812e60..d2ce0f08a3 100644
--- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Shutdown.java
+++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/Shutdown.java
@@ -82,7 +82,7 @@ public final class Shutdown extends Thread {
}
/**
- * Invoked if the Apache SIS library is executed from an environment that
provide its own shutdown hook.
+ * Invoked if the Apache SIS library is executed from an environment that
provides its own shutdown hook.
* Example of such environments are OSGi and servlet containers. In such
case, the shutdown hook will not
* be registered to the JVM {@link Runtime}.
*
@@ -152,6 +152,7 @@ public final class Shutdown extends Thread {
* @throws Exception if an error occurred during unregistration of the
supervisor MBean
* or during a resource disposal.
*/
+ @SuppressWarnings("UseSpecificCatch")
public static void stop(final Class<?> caller) throws Exception {
synchronized (resources) {
container = "Shutdown";
diff --git
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/SystemListener.java
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/SystemListener.java
index 9a0c3f5956..f9fe2e354f 100644
---
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/SystemListener.java
+++
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/system/SystemListener.java
@@ -106,7 +106,7 @@ public abstract class SystemListener implements
EventListener {
final SystemListener[] list = listeners;
if (list != null) {
int count = 0;
- final SystemListener[] modified = new
SystemListener[list.length];
+ final var modified = new SystemListener[list.length];
for (final SystemListener listener : list) {
if (!name.equals(listener.module)) {
modified[count++] = listener;
diff --git a/incubator/build.gradle.kts b/incubator/build.gradle.kts
index d0c9433efd..1d946daed6 100644
--- a/incubator/build.gradle.kts
+++ b/incubator/build.gradle.kts
@@ -65,6 +65,7 @@ dependencies {
implementation(group = "org.antlr", name =
"antlr4-maven-plugin", version = "4.13.2")
implementation(group = "org.xerial", name = "sqlite-jdbc",
version = "3.45.1.0")
compileOnly (group = "jakarta.servlet", name =
"jakarta.servlet-api", version = "6.1.0")
+ compileOnly (group = "javax.servlet", name =
"javax.servlet-api", version = "4.0.1")
compileOnly (group = "org.osgi", name = "osgi.core",
version = "8.0.0")
antlr (group = "org.antlr", name = "antlr4",
version = "4.13.2")
}
diff --git
a/incubator/src/org.apache.sis.webapp/main/META-INF/services/jakarta.servlet.ServletContainerInitializer
b/incubator/src/org.apache.sis.webapp/main/META-INF/services/jakarta.servlet.ServletContainerInitializer
new file mode 100644
index 0000000000..148d4db4b4
--- /dev/null
+++
b/incubator/src/org.apache.sis.webapp/main/META-INF/services/jakarta.servlet.ServletContainerInitializer
@@ -0,0 +1 @@
+org.apache.sis.services.ServletListener
diff --git
a/incubator/src/org.apache.sis.webapp/main/META-INF/services/javax.servlet.ServletContainerInitializer
b/incubator/src/org.apache.sis.webapp/main/META-INF/services/javax.servlet.ServletContainerInitializer
new file mode 100644
index 0000000000..581d97a4e8
--- /dev/null
+++
b/incubator/src/org.apache.sis.webapp/main/META-INF/services/javax.servlet.ServletContainerInitializer
@@ -0,0 +1 @@
+org.apache.sis.services.ServletListenerLegacy
diff --git a/incubator/src/org.apache.sis.webapp/main/module-info.java
b/incubator/src/org.apache.sis.webapp/main/module-info.java
index 43c4598011..2edbfb846a 100644
--- a/incubator/src/org.apache.sis.webapp/main/module-info.java
+++ b/incubator/src/org.apache.sis.webapp/main/module-info.java
@@ -16,12 +16,26 @@
*/
/**
- * Place-holder for future web services.
+ * Support the use of Apache <abbr>SIS</abbr> in web containers.
+ * Web applications having <abbr>SIS</abbr> in their dependencies can add this
module
+ * if they need to undeploy <abbr>SIS</abbr> cleanly while keeping the rest of
the container running.
+ * This module is compatible with:
+ *
+ * <ul>
+ * <li>JavaEE Servlet 4.0 ({@code javax.servlet} packages)</li>
+ * <li>Jakarta Servlet 6.1 ({@code jakarta.servlet} packages)</li>
+ * <li>OGSGi 8.0 ({@code org.osgi} packages)</li>
+ * </ul>
*/
module org.apache.sis.webapp {
- requires transitive org.apache.sis.storage;
+ requires transitive org.apache.sis.util;
requires static jakarta.servlet;
+ requires static javax.servlet.api;
requires static osgi.core;
- exports org.apache.sis.services;
+ provides jakarta.servlet.ServletContainerInitializer
+ with org.apache.sis.services.ServletListener;
+
+ provides javax.servlet.ServletContainerInitializer
+ with org.apache.sis.services.ServletListenerLegacy;
}
diff --git
a/incubator/src/org.apache.sis.webapp/main/org/apache/sis/services/Servlet.java
b/incubator/src/org.apache.sis.webapp/main/org/apache/sis/services/Servlet.java
deleted file mode 100644
index c3d4b5e1a7..0000000000
---
a/incubator/src/org.apache.sis.webapp/main/org/apache/sis/services/Servlet.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sis.services;
-
-
-/**
- * Place-holder for future web services.
- */
-public final class Servlet {
- private Servlet() {
- }
-}
diff --git
a/incubator/src/org.apache.sis.webapp/main/org/apache/sis/services/ServletListener.java
b/incubator/src/org.apache.sis.webapp/main/org/apache/sis/services/ServletListener.java
index 4772179044..e0ba6e6c85 100644
---
a/incubator/src/org.apache.sis.webapp/main/org/apache/sis/services/ServletListener.java
+++
b/incubator/src/org.apache.sis.webapp/main/org/apache/sis/services/ServletListener.java
@@ -16,8 +16,12 @@
*/
package org.apache.sis.services;
+import java.util.Set;
+import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletContextEvent;
import jakarta.servlet.ServletContextListener;
+import jakarta.servlet.ServletContainerInitializer;
+import jakarta.servlet.annotation.HandlesTypes;
import jakarta.servlet.annotation.WebListener;
import org.apache.sis.system.Shutdown;
@@ -29,21 +33,23 @@ import org.apache.sis.system.Shutdown;
* @author Martin Desruisseaux (Geomatys)
*/
@WebListener("Apache SIS shutdown hook")
-public final class ServletListener implements ServletContextListener {
+public final class ServletListener implements ServletContainerInitializer,
ServletContextListener {
/**
- * Invoked by reflection by the container.
+ * Invoked by reflection by the service loader.
*/
public ServletListener() {
}
/**
- * Receives notification that the web application initialization process
is starting.
+ * Notifies Apache <abbr>SIS</abbr> that the application is initializing.
*
- * @param event the context of the servlet being initialized.
+ * @param handled classes declared by {@link HandlesTypes}, or {@code
null} if none.
+ * @param context context of the web application in which the classes
were discovered.
*/
@Override
- public void contextInitialized(final ServletContextEvent event) {
- final String env = event.getServletContext().getServerInfo();
+ public void onStartup(final Set<Class<?>> handled, final ServletContext
context) {
+ context.addListener(this);
+ final String env = context.getServerInfo();
Shutdown.setContainer(env != null ? env : "Servlet");
}
diff --git
a/incubator/src/org.apache.sis.webapp/main/org/apache/sis/services/ServletListener.java
b/incubator/src/org.apache.sis.webapp/main/org/apache/sis/services/ServletListenerLegacy.java
similarity index 60%
copy from
incubator/src/org.apache.sis.webapp/main/org/apache/sis/services/ServletListener.java
copy to
incubator/src/org.apache.sis.webapp/main/org/apache/sis/services/ServletListenerLegacy.java
index 4772179044..15cebb477f 100644
---
a/incubator/src/org.apache.sis.webapp/main/org/apache/sis/services/ServletListener.java
+++
b/incubator/src/org.apache.sis.webapp/main/org/apache/sis/services/ServletListenerLegacy.java
@@ -16,34 +16,39 @@
*/
package org.apache.sis.services;
-import jakarta.servlet.ServletContextEvent;
-import jakarta.servlet.ServletContextListener;
-import jakarta.servlet.annotation.WebListener;
+import java.util.Set;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletContainerInitializer;
+import javax.servlet.annotation.HandlesTypes;
+import javax.servlet.annotation.WebListener;
import org.apache.sis.system.Shutdown;
/**
- * Listener for servlet context, used as a shutdown hook when the application
is undeployed.
- * This class should not be used directly.
+ * Copy of {@link ServletListener} using the JaveEE package name instead of
Jakarta.
*
* @author Martin Desruisseaux (Geomatys)
*/
@WebListener("Apache SIS shutdown hook")
-public final class ServletListener implements ServletContextListener {
+public final class ServletListenerLegacy implements
ServletContainerInitializer, ServletContextListener {
/**
- * Invoked by reflection by the container.
+ * Invoked by reflection by the service loader.
*/
- public ServletListener() {
+ public ServletListenerLegacy() {
}
/**
- * Receives notification that the web application initialization process
is starting.
+ * Notifies Apache <abbr>SIS</abbr> that the application is initializing.
*
- * @param event the context of the servlet being initialized.
+ * @param handled classes declared by {@link HandlesTypes}, or {@code
null} if none.
+ * @param context context of the web application in which the classes
were discovered.
*/
@Override
- public void contextInitialized(final ServletContextEvent event) {
- final String env = event.getServletContext().getServerInfo();
+ public void onStartup(final Set<Class<?>> handled, final ServletContext
context) {
+ context.addListener(this);
+ final String env = context.getServerInfo();
Shutdown.setContainer(env != null ? env : "Servlet");
}
diff --git
a/incubator/src/org.apache.sis.webapp/main/org/apache/sis/services/package-info.java
b/incubator/src/org.apache.sis.webapp/main/org/apache/sis/services/package-info.java
index 25ac79492a..a9635f5bfc 100644
---
a/incubator/src/org.apache.sis.webapp/main/org/apache/sis/services/package-info.java
+++
b/incubator/src/org.apache.sis.webapp/main/org/apache/sis/services/package-info.java
@@ -16,6 +16,6 @@
*/
/**
- * Place-holder for future web services.
+ * Tasks to execute at initialization and undeploy time.
*/
package org.apache.sis.services;
diff --git a/incubator/src/org.apache.sis.webapp/webapp/META-INF/context.xml
b/incubator/src/org.apache.sis.webapp/webapp/META-INF/context.xml
deleted file mode 100644
index 0834995348..0000000000
--- a/incubator/src/org.apache.sis.webapp/webapp/META-INF/context.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one or more contributor
-license agreements. See the NOTICE file distributed with this work for
-additional information regarding copyright ownership. The ASF licenses this
-file to you under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-
-<Context path="/sis" docBase="/path/to/org.apache.sis.webapp.war">
-
- <!-- TODO: this file is only a template. Need to be edited. -->
-
- <Parameter name="org.apache.sis.services.config.filePath"
- value="/path/to/sis-location-config.xml" override="false"/>
-
-</Context>
diff --git a/netbeans-project/ivy.xml b/netbeans-project/ivy.xml
index 8d772cd9af..c998d5b478 100644
--- a/netbeans-project/ivy.xml
+++ b/netbeans-project/ivy.xml
@@ -26,6 +26,7 @@
<dependency org="org.libreoffice" name="libreoffice"
rev="26.2.2"/>
<dependency org="software.amazon.awssdk" name="s3"
rev="2.55.9"/>
<dependency org="org.antlr" name="antlr4-maven-plugin"
rev="4.13.2"/>
+ <dependency org="javax.servlet" name="javax.servlet-api"
rev="4.0.1"/>
<dependency org="jakarta.servlet" name="jakarta.servlet-api"
rev="6.1.0"/>
<dependency org="org.osgi" name="osgi.core"
rev="8.0.0"/>
<dependency org="org.junit.platform"
name="junit-platform-launcher" rev="1.10.3"/>