This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit ad687670cb6324752422ef6358081ec7211d3ad3 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Sat Dec 10 16:25:34 2022 +0100 Remove OSGi dependency from core SIS modules. OSGi support has never been completed anyway. The class moved to `sis-webapp` in case we want to try again in the future. --- application/sis-webapp/pom.xml | 8 ++++++++ .../main/java/org/apache/sis/services}/OSGiActivator.java | 4 +++- core/sis-metadata/src/main/java/org/apache/sis/xml/XML.java | 8 ++++---- core/sis-utility/pom.xml | 12 ------------ .../org/apache/sis/internal/converter/SystemRegistry.java | 7 ++++--- .../java/org/apache/sis/internal/converter/package-info.java | 7 +++---- .../java/org/apache/sis/internal/system/SystemListener.java | 3 +-- ide-project/NetBeans/nbproject/project.properties | 4 +--- pom.xml | 6 ------ 9 files changed, 24 insertions(+), 35 deletions(-) diff --git a/application/sis-webapp/pom.xml b/application/sis-webapp/pom.xml index c59f243964..f39fd38c38 100644 --- a/application/sis-webapp/pom.xml +++ b/application/sis-webapp/pom.xml @@ -44,6 +44,14 @@ <version>8.0.1</version> <scope>provided</scope> </dependency> + + <!-- Optional dependencies --> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <version>6.0.0</version> + <scope>provided</scope> + </dependency> </dependencies> </project> diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/system/OSGiActivator.java b/application/sis-webapp/src/main/java/org/apache/sis/services/OSGiActivator.java similarity index 95% rename from core/sis-utility/src/main/java/org/apache/sis/internal/system/OSGiActivator.java rename to application/sis-webapp/src/main/java/org/apache/sis/services/OSGiActivator.java index 1c8f9a83f7..2a3d4b725a 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/internal/system/OSGiActivator.java +++ b/application/sis-webapp/src/main/java/org/apache/sis/services/OSGiActivator.java @@ -14,12 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.sis.internal.system; +package org.apache.sis.services; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleEvent; import org.osgi.framework.BundleListener; +import org.apache.sis.internal.system.Shutdown; +import org.apache.sis.internal.system.SystemListener; /** diff --git a/core/sis-metadata/src/main/java/org/apache/sis/xml/XML.java b/core/sis-metadata/src/main/java/org/apache/sis/xml/XML.java index 31ec54506d..204af20a66 100644 --- a/core/sis-metadata/src/main/java/org/apache/sis/xml/XML.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/xml/XML.java @@ -378,8 +378,8 @@ public final class XML extends Static { * The field name uses the uppercase convention because this field is almost constant: * this field is initially null, then created by {@link #getPool()} when first needed. * Once created the field value usually doesn't change. However, the field may be reset - * to {@code null} in an OSGi context when modules are loaded or unloaded, because the - * set of classes returned by {@link TypeRegistration#load(boolean)} may have changed. + * to {@code null} when modules are loaded or unloaded by a container such as OSGi, + * because the set of classes returned by {@link TypeRegistration#load(boolean)} may have changed. * * @see #getPool() */ @@ -409,8 +409,8 @@ public final class XML extends Static { * <div class="note"><b>Implementation note:</b> * Current implementation uses the double-check idiom. This is usually a deprecated practice * (the recommended alterative is to use static class initialization), but in this particular - * case the field may be reset to {@code null} if OSGi modules are loaded or unloaded, so static - * class initialization would be a little bit too rigid.</div> + * case the field may be reset to {@code null} if modules are loaded or unloaded by a container, + * so static class initialization would be a little bit too rigid.</div> */ @SuppressWarnings("DoubleCheckedLocking") private static MarshallerPool getPool() throws JAXBException { diff --git a/core/sis-utility/pom.xml b/core/sis-utility/pom.xml index e314d97b1a..b486274f4f 100644 --- a/core/sis-utility/pom.xml +++ b/core/sis-utility/pom.xml @@ -136,16 +136,4 @@ </plugins> </build> - - <!-- =========================================================== - Dependencies - =========================================================== --> - <dependencies> - <!-- Optional dependencies (provided scope) --> - <dependency> - <groupId>org.osgi</groupId> - <artifactId>org.osgi.core</artifactId> - </dependency> - </dependencies> - </project> diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/SystemRegistry.java b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/SystemRegistry.java index f3997a5bba..97a3079ab5 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/SystemRegistry.java +++ b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/SystemRegistry.java @@ -70,9 +70,10 @@ public final class SystemRegistry extends ConverterRegistry { /* * Force reloading of META-INF/services files if the classpath changed, * since the set of reachable META-INF/services files may have changed. - * If any converters were registered by explicit calls to the 'register' method, - * then those converters are lost. This is of concern only for applications using - * a modularization framework like OSGi. See package javadoc for more information. + * If any converters were registered by explicit calls to the `register` method, + * then those converters are lost. This is of concern only for applications + * using a container framework such as Servlet or OSGi. + * See package javadoc for more information. */ SystemListener.add(new SystemListener(Modules.UTILITIES) { @Override protected void classpathChanged() { diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/package-info.java b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/package-info.java index 9a4e383ee3..76a4ad6a7c 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/internal/converter/package-info.java +++ b/core/sis-utility/src/main/java/org/apache/sis/internal/converter/package-info.java @@ -32,10 +32,9 @@ * META-INF/services/org.apache.sis.util.ObjectConverter * } * - * Applications deployed in a modularization framework like OSGi shall use only the - * {@code META-INF} approach, because system converters are discarded every time the - * classpath changes. Having the converters declared in {@code META-INF} ensure that - * they will be reloaded when needed. + * Applications deployed in a container framework like OSGi shall use only the service loader, + * because system converters are discarded every time that the classpath changes. + * Having the converters declared in {@code META-INF} ensure that they will be reloaded when needed. * * <p>Alternatively, applications can also use their own {@code ConverterRegistry} instance. * Non-system instances do not scan for {@code META-INF} and do not discard their content on diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/system/SystemListener.java b/core/sis-utility/src/main/java/org/apache/sis/internal/system/SystemListener.java index ad7a43d75f..2283d1b0f2 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/internal/system/SystemListener.java +++ b/core/sis-utility/src/main/java/org/apache/sis/internal/system/SystemListener.java @@ -94,12 +94,11 @@ public abstract class SystemListener implements EventListener { /** * Removes all listeners for the module of the given name. - * This method is invoked by {@link OSGiActivator}. * * @param name the name of the module for which to remove listeners, or {@code null} if the module * to uninstall does not have symbolic name (in which case it is probably not a SIS module). */ - static synchronized void removeModule(final String name) { + public static synchronized void removeModule(final String name) { if (name != null) { final SystemListener[] list = listeners; if (list != null) { diff --git a/ide-project/NetBeans/nbproject/project.properties b/ide-project/NetBeans/nbproject/project.properties index e6ace69739..e537f44c7a 100644 --- a/ide-project/NetBeans/nbproject/project.properties +++ b/ide-project/NetBeans/nbproject/project.properties @@ -110,7 +110,6 @@ re2j.version = 1.3 esri.api.version = 2.2.4 jts.version = 1.19.0 jdom2.version = 2.0.6 -osgi.version = 6.0.0 netcdf.version = 5.5.3 joda-time.version = 2.10.3 httpclient.version = 4.5.13 @@ -139,8 +138,7 @@ javac.classpath=\ ${maven.repository}/org/postgresql/postgresql/${postgresql.version}/postgresql-${postgresql.version}.jar:\ ${maven.repository}/edu/ucar/cdm-core/${netcdf.version}/cdm-core-${netcdf.version}.jar:\ ${maven.repository}/edu/ucar/udunits/${netcdf.version}/udunits-${netcdf.version}.jar:\ - ${maven.repository}/com/google/guava/guava/${guava.version}/guava-${guava.version}.jar:\ - ${maven.repository}/org/osgi/org.osgi.core/${osgi.version}/org.osgi.core-${osgi.version}.jar + ${maven.repository}/com/google/guava/guava/${guava.version}/guava-${guava.version}.jar javac.processorpath=\ ${javac.classpath} javac.test.classpath=\ diff --git a/pom.xml b/pom.xml index 416481c0fd..3e85c4c59f 100644 --- a/pom.xml +++ b/pom.xml @@ -509,12 +509,6 @@ </dependency> <!-- Optional dependencies --> - <dependency> - <groupId>org.osgi</groupId> - <artifactId>org.osgi.core</artifactId> - <version>6.0.0</version> - <scope>provided</scope> - </dependency> <dependency> <groupId>edu.ucar</groupId> <artifactId>cdm-core</artifactId>