From 769354e0b701f8de11b42b03a4fa790fd4200882 Mon Sep 17 00:00:00 2001 From: Thierry Boileau Date: Sat, 17 Oct 2026 11:51:47 +0200 Subject: [PATCH] Drop support of OSGi. Issue #1535. --- changes.md | 5 + org.restlet.ext.crypto/pom.xml | 10 -- org.restlet.ext.freemarker/pom.xml | 10 -- org.restlet.ext.gson/pom.xml | 10 -- org.restlet.ext.jaas/pom.xml | 10 -- org.restlet.ext.jackson/pom.xml | 10 -- .../jackson/internal/XmlFactoryProvider.java | 64 +------- org.restlet.ext.json/pom.xml | 10 -- org.restlet.ext.openapi/pom.xml | 10 -- org.restlet.ext.slf4j/pom.xml | 10 -- org.restlet.ext.spring/pom.xml | 10 -- org.restlet.ext.thymeleaf/pom.xml | 10 -- org.restlet.ext.velocity/pom.xml | 10 -- org.restlet.ext.xml/pom.xml | 10 -- org.restlet/pom.xml | 19 --- org.restlet/src/main/java/module-info.java | 1 - .../restlet/engine/internal/Activator.java | 144 ------------------ pom.xml | 6 - 18 files changed, 10 insertions(+), 349 deletions(-) delete mode 100644 org.restlet/src/main/java/org/restlet/engine/internal/Activator.java diff --git a/changes.md b/changes.md index 886ac59a5e..c997c83e2d 100644 --- a/changes.md +++ b/changes.md @@ -2,6 +2,11 @@ Changes log =========== - 3.0 Milestone 2 (??-??-2026) + - Breaking changes + - Removed the OSGi support: the `Activator`, the `osgi.core` dependency and the bundle + packaging (Maven artifacts are now plain JARs, without `Bundle-*` manifest headers). + `XmlFactoryProvider` of the Jackson extension now relies on the plain `ServiceLoader`. + OSGi users should stay on 2.x. - Bugs fixed - Slf4j bridge reports wrong line number and caller class in log4j. Issue #233. - When GET is an allowed method of a server resource, HEAD is now also listed (e.g. in the Allow header of a 405 response). Issue #266. diff --git a/org.restlet.ext.crypto/pom.xml b/org.restlet.ext.crypto/pom.xml index eb4fa1a640..3955777648 100644 --- a/org.restlet.ext.crypto/pom.xml +++ b/org.restlet.ext.crypto/pom.xml @@ -10,7 +10,6 @@ org.restlet.ext.crypto - bundle Restlet Framework - Crypto extension Support for cryptography. @@ -27,13 +26,4 @@ test - - - - org.apache.felix - maven-bundle-plugin - true - - - diff --git a/org.restlet.ext.freemarker/pom.xml b/org.restlet.ext.freemarker/pom.xml index cec2065a2b..31af425a9b 100644 --- a/org.restlet.ext.freemarker/pom.xml +++ b/org.restlet.ext.freemarker/pom.xml @@ -10,7 +10,6 @@ org.restlet.ext.freemarker - bundle Restlet Framework - FreeMarker extension Integration with FreeMarker. @@ -32,13 +31,4 @@ test - - - - org.apache.felix - maven-bundle-plugin - true - - - diff --git a/org.restlet.ext.gson/pom.xml b/org.restlet.ext.gson/pom.xml index 0ed1f59e91..b268498db1 100644 --- a/org.restlet.ext.gson/pom.xml +++ b/org.restlet.ext.gson/pom.xml @@ -10,7 +10,6 @@ org.restlet.ext.gson - bundle Restlet Framework - GSON extension Support for GSON representations. @@ -37,13 +36,4 @@ test - - - - org.apache.felix - maven-bundle-plugin - true - - - diff --git a/org.restlet.ext.jaas/pom.xml b/org.restlet.ext.jaas/pom.xml index 68a93fd18a..4b989c9ec6 100644 --- a/org.restlet.ext.jaas/pom.xml +++ b/org.restlet.ext.jaas/pom.xml @@ -10,7 +10,6 @@ org.restlet.ext.jaas - bundle Restlet Framework - JAAS extension Support for JAAS based security. @@ -27,13 +26,4 @@ test - - - - org.apache.felix - maven-bundle-plugin - true - - - diff --git a/org.restlet.ext.jackson/pom.xml b/org.restlet.ext.jackson/pom.xml index 77a9a3b4e3..ce20625251 100644 --- a/org.restlet.ext.jackson/pom.xml +++ b/org.restlet.ext.jackson/pom.xml @@ -10,7 +10,6 @@ org.restlet.ext.jackson - bundle Restlet Framework - Jackson extension Integration with Jackson. @@ -82,13 +81,4 @@ test - - - - org.apache.felix - maven-bundle-plugin - true - - - diff --git a/org.restlet.ext.jackson/src/main/java/org/restlet/ext/jackson/internal/XmlFactoryProvider.java b/org.restlet.ext.jackson/src/main/java/org/restlet/ext/jackson/internal/XmlFactoryProvider.java index 84946f1448..191b640523 100644 --- a/org.restlet.ext.jackson/src/main/java/org/restlet/ext/jackson/internal/XmlFactoryProvider.java +++ b/org.restlet.ext.jackson/src/main/java/org/restlet/ext/jackson/internal/XmlFactoryProvider.java @@ -10,80 +10,26 @@ import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLOutputFactory; -import org.codehaus.stax2.osgi.Stax2InputFactoryProvider; -import org.codehaus.stax2.osgi.Stax2OutputFactoryProvider; -import org.restlet.engine.Edition; /** - * Provides {@link javax.xml.stream.XMLInputFactory} and {@link javax.xml.stream.XMLOutputFactory} - * in an OSGI context. - * - *

In a non-OSGI context, the factories are retrieved with java service loader. + * Provides {@link javax.xml.stream.XMLInputFactory} and {@link javax.xml.stream.XMLOutputFactory}. + * The factories are retrieved with the Java service loader. * * @author Manuel Boillod */ public class XmlFactoryProvider { - /** - * Allow explicitly setting the Stax2InputFactory instance in OSGI context. In a no-OSGI - * context, the factory is retrieved with a java service loader. - * - *

Note: Stax2 implementation is provided by woodstox library, which is a dependency of - * Jackson. - */ - public static Stax2InputFactoryProvider inputFactoryProvider = null; - - /** - * Allow explicitly setting the Stax2OutputFactoryProvider instance in OSGI context. In a - * no-OSGI context, the factory is retrieved with a java service loader. - * - *

Note: Stax2 implementation is provided by woodstox library, which is a dependency of - * Jackson. - */ - public static Stax2OutputFactoryProvider outputFactoryProvider = null; - /** * Returns an instance of {@link javax.xml.stream.XMLInputFactory} according to the classpath. */ public static XMLInputFactory newInputFactory() { - if (inputFactoryProvider == null) { - if (Edition.ANDROID.isCurrentEdition()) { - inputFactoryProvider = - (Stax2InputFactoryProvider) - newProvider("com.ctc.wstx.osgi.InputFactoryProviderImpl"); - } else { - return XMLInputFactory.newFactory(); - } - } - return inputFactoryProvider.createInputFactory(); + return XMLInputFactory.newFactory(); } /** - * Returns an instance of {@link javax.xml.stream.XMLInputFactory} according to the classpath. + * Returns an instance of {@link javax.xml.stream.XMLOutputFactory} according to the classpath. */ public static XMLOutputFactory newOutputFactory() { - if (outputFactoryProvider == null) { - if (Edition.ANDROID.isCurrentEdition()) { - outputFactoryProvider = - (Stax2OutputFactoryProvider) - newProvider("com.ctc.wstx.osgi.OutputFactoryProviderImpl"); - } else { - return XMLOutputFactory.newFactory(); - } - } - - return outputFactoryProvider.createOutputFactory(); - } - - /** - * Instantiates a Woodstox provider by name. The OSGi package of Woodstox isn't exported by its - * Java module, which would prevent a direct reference. - */ - private static Object newProvider(String className) { - try { - return Class.forName(className).getDeclaredConstructor().newInstance(); - } catch (ReflectiveOperationException e) { - throw new IllegalStateException("Unable to instantiate " + className, e); - } + return XMLOutputFactory.newFactory(); } } diff --git a/org.restlet.ext.json/pom.xml b/org.restlet.ext.json/pom.xml index 496e261fe2..139e6363b6 100644 --- a/org.restlet.ext.json/pom.xml +++ b/org.restlet.ext.json/pom.xml @@ -10,7 +10,6 @@ org.restlet.ext.json - bundle Restlet Framework - JSON extension Support for JSON representations. @@ -32,13 +31,4 @@ test - - - - org.apache.felix - maven-bundle-plugin - true - - - diff --git a/org.restlet.ext.openapi/pom.xml b/org.restlet.ext.openapi/pom.xml index 40c117a385..5d6480f921 100644 --- a/org.restlet.ext.openapi/pom.xml +++ b/org.restlet.ext.openapi/pom.xml @@ -11,7 +11,6 @@ org.restlet.ext.openapi - bundle Restlet Framework - OpenAPI extension Support for the OpenAPI specification. @@ -123,13 +122,4 @@ - - - - org.apache.felix - maven-bundle-plugin - true - - - \ No newline at end of file diff --git a/org.restlet.ext.slf4j/pom.xml b/org.restlet.ext.slf4j/pom.xml index 39a6f6cd03..c42ab9f34d 100644 --- a/org.restlet.ext.slf4j/pom.xml +++ b/org.restlet.ext.slf4j/pom.xml @@ -10,7 +10,6 @@ org.restlet.ext.slf4j - bundle Restlet Framework - SLF4J extension Support for the SLF4J logging bridge. @@ -32,13 +31,4 @@ test - - - - org.apache.felix - maven-bundle-plugin - true - - - diff --git a/org.restlet.ext.spring/pom.xml b/org.restlet.ext.spring/pom.xml index 52af2e3069..fc5d6f4884 100644 --- a/org.restlet.ext.spring/pom.xml +++ b/org.restlet.ext.spring/pom.xml @@ -10,7 +10,6 @@ org.restlet.ext.spring - bundle Restlet Framework - Spring extension Integration with Spring Framework. @@ -42,13 +41,4 @@ test - - - - org.apache.felix - maven-bundle-plugin - true - - - diff --git a/org.restlet.ext.thymeleaf/pom.xml b/org.restlet.ext.thymeleaf/pom.xml index d5b998e62a..143259dc84 100644 --- a/org.restlet.ext.thymeleaf/pom.xml +++ b/org.restlet.ext.thymeleaf/pom.xml @@ -10,7 +10,6 @@ org.restlet.ext.thymeleaf - bundle Restlet Framework - Thymeleaf extension Integration with Thymeleaf. @@ -32,13 +31,4 @@ test - - - - org.apache.felix - maven-bundle-plugin - true - - - diff --git a/org.restlet.ext.velocity/pom.xml b/org.restlet.ext.velocity/pom.xml index 240a1a3df0..c93caaf482 100644 --- a/org.restlet.ext.velocity/pom.xml +++ b/org.restlet.ext.velocity/pom.xml @@ -10,7 +10,6 @@ org.restlet.ext.velocity - bundle Restlet Framework - Velocity extension Integration with Apache Velocity. @@ -36,13 +35,4 @@ test - - - - org.apache.felix - maven-bundle-plugin - true - - - diff --git a/org.restlet.ext.xml/pom.xml b/org.restlet.ext.xml/pom.xml index b3bc8ca136..fa510767a3 100644 --- a/org.restlet.ext.xml/pom.xml +++ b/org.restlet.ext.xml/pom.xml @@ -10,7 +10,6 @@ org.restlet.ext.xml - bundle Restlet Framework - XML extension Support for the XML documents. @@ -27,13 +26,4 @@ test - - - - org.apache.felix - maven-bundle-plugin - true - - - diff --git a/org.restlet/pom.xml b/org.restlet/pom.xml index b918f2ac1e..c1e1bc4cfa 100644 --- a/org.restlet/pom.xml +++ b/org.restlet/pom.xml @@ -11,7 +11,6 @@ org.restlet Restlet Framework - Core - bundle Restlet API and Engine @@ -100,13 +99,6 @@ jetty-quic-client ${lib-jetty-version} - - org.osgi - osgi.core - ${lib-osgi-version} - provided - true - org.junit.jupiter @@ -181,17 +173,6 @@ - - org.apache.felix - maven-bundle-plugin - true - - - org.restlet.engine.internal - org.restlet.engine.internal.Activator - - - diff --git a/org.restlet/src/main/java/module-info.java b/org.restlet/src/main/java/module-info.java index 32af1bb6f0..078e6b65b5 100644 --- a/org.restlet/src/main/java/module-info.java +++ b/org.restlet/src/main/java/module-info.java @@ -26,7 +26,6 @@ requires transitive org.eclipse.jetty.util; requires transitive org.eclipse.jetty.quic.client; requires transitive org.eclipse.jetty.quic.server; - requires static osgi.core; exports org.restlet; exports org.restlet.data; diff --git a/org.restlet/src/main/java/org/restlet/engine/internal/Activator.java b/org.restlet/src/main/java/org/restlet/engine/internal/Activator.java deleted file mode 100644 index 638a1c293f..0000000000 --- a/org.restlet/src/main/java/org/restlet/engine/internal/Activator.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * Copyright 2005-2026 Qlik - *

- * The content of this file is subject to the terms of the Apache 2.0 open - * source license available at https://www.opensource.org/licenses/apache-2.0 - *

- * Restlet is a registered trademark of QlikTech International AB. - */ -package org.restlet.engine.internal; - -import java.net.URL; -import java.util.List; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.BundleEvent; -import org.restlet.Client; -import org.restlet.Server; -import org.restlet.engine.Engine; - -/** - * OSGi activator. It registers the NRE into the Restlet API and also introspects the bundles to - * find connector or authentication helpers. - * - * @author Jerome Louvel - */ -public class Activator implements BundleActivator { - - /** - * Registers the helpers for a given bundle. - * - * @param bundle The bundle to inspect. - * @param helpers The helpers list to update. - * @param constructorClass The class to use as a constructor parameter. - * @param descriptorPath The descriptor file path. - */ - private void registerHelper( - Bundle bundle, List helpers, Class constructorClass, String descriptorPath) { - // Discover server helpers - URL configUrl = bundle.getEntry(descriptorPath); - - if (configUrl == null) { - configUrl = bundle.getEntry("/src/" + descriptorPath); - } - - if (configUrl != null) { - registerHelper(bundle, helpers, constructorClass, configUrl); - } - } - - /** - * Registers the helpers for a given bundle. - * - * @param bundle The bundle to inspect. - * @param helpers The helpers list to update. - * @param constructorClass The class to use as a constructor parameter. - * @param descriptorUrl The descriptor URL to inspect. - */ - private void registerHelper( - final Bundle bundle, List helpers, Class constructorClass, URL descriptorUrl) { - Engine.getInstance() - .registerHelpers( - new ClassLoader() { - @Override - public Class loadClass(String name) throws ClassNotFoundException { - return bundle.loadClass(name); - } - }, - descriptorUrl, - helpers, - constructorClass); - } - - /** - * Registers the helpers for a given bundle. - * - * @param bundle The bundle to inspect. - */ - private void registerHelpers(Bundle bundle) { - // Register server helpers - registerHelper( - bundle, - Engine.getInstance().getRegisteredServers(), - Server.class, - Engine.DESCRIPTOR_SERVER_PATH); - - // Register client helpers - registerHelper( - bundle, - Engine.getInstance().getRegisteredClients(), - Client.class, - Engine.DESCRIPTOR_CLIENT_PATH); - - // Register authentication helpers - registerHelper( - bundle, - Engine.getInstance().getRegisteredAuthenticators(), - null, - Engine.DESCRIPTOR_AUTHENTICATOR_PATH); - - // Register converter helpers - registerHelper( - bundle, - Engine.getInstance().getRegisteredConverters(), - null, - Engine.DESCRIPTOR_CONVERTER_PATH); - } - - /** - * Starts the OSGi bundle by registering the engine with the bundle of the Restlet API. - * - * @param context The bundle context. - */ - public void start(BundleContext context) throws Exception { - org.restlet.engine.Engine.register(false); - - // Discover helpers in installed bundles and start - // the bundle if necessary - for (final Bundle bundle : context.getBundles()) { - registerHelpers(bundle); - } - - // Listen to installed bundles - context.addBundleListener( - event -> { - if (event.getType() == BundleEvent.INSTALLED) { - registerHelpers(event.getBundle()); - } - }); - - Engine.getInstance().registerDefaultConnectors(); - Engine.getInstance().registerDefaultAuthentications(); - Engine.getInstance().registerDefaultConverters(); - } - - /** - * Stops the OSGi bundle by unregistering the engine with the bundle of the Restlet API. - * - * @param context The bundle context. - */ - public void stop(BundleContext context) throws Exception { - org.restlet.engine.Engine.clear(); - } -} diff --git a/pom.xml b/pom.xml index 33f932c1a7..0536113ee4 100644 --- a/pom.xml +++ b/pom.xml @@ -61,7 +61,6 @@ 12.0.39 20260522 3.0 - 8.0.0 2.0.18 7.0.8 2.2.55 @@ -544,11 +543,6 @@ maven-release-plugin 3.3.1 - - org.apache.felix - maven-bundle-plugin - 6.2.0 -