From 6085f9d9591e4a5014f22b4c0e474b0ee5e1faef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raymond=20Aug=C3=A9?= Date: Tue, 5 Oct 2021 15:53:57 -0400 Subject: [PATCH 1/2] OSGi import/export headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - element added to silence a complaint from bnd about well formed entries - let bnd generate default manifest spec entries, as well as setting all other headers - added BND SPI annotations to add the necessary parts to make ServiceLoader work in OSGi (passively) fixes #242 Signed-off-by: Raymond Augé --- .gitignore | 5 ++ pom.xml | 51 ++++++++++++++++--- r2dbc-spi-test/pom.xml | 14 ++--- r2dbc-spi/pom.xml | 26 +++++++--- .../r2dbc/spi/ConnectionFactoryProvider.java | 14 +++++ 5 files changed, 87 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 79f736d..fd996a1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,11 @@ dependency-reduced-pom.xml buildNumber.properties .mvn/timing.properties +# Eclipse +.project +.classpath +.settings + # IntelliJ out/ build/ diff --git a/pom.xml b/pom.xml index 698aedf..7964d22 100644 --- a/pom.xml +++ b/pom.xml @@ -41,6 +41,9 @@ 3.0.2 5.7.0 3.17.2 + 6.0.0 + 8.0.0 + 1 UTF-8 UTF-8 1.0.3 @@ -62,18 +65,22 @@ + nebhale Ben Hale bhale@pivotal.io + mp911de Mark Paluch mpaluch@vmware.com + mirromutth Mirro Mutth mirromutth@gmail.com + gregturn Greg Turnquist gturnquist@pivotal.io @@ -106,6 +113,43 @@ + + biz.aQute.bnd + bnd-maven-plugin + ${bnd.version} + + + + bnd-process + + + + + + + org.apache.maven.plugins maven-compiler-plugin @@ -129,12 +173,7 @@ 3.2.0 - - true - - - ${project.version} - + ${project.build.outputDirectory}/META-INF/MANIFEST.MF diff --git a/r2dbc-spi-test/pom.xml b/r2dbc-spi-test/pom.xml index e0c3469..5fb1ed2 100644 --- a/r2dbc-spi-test/pom.xml +++ b/r2dbc-spi-test/pom.xml @@ -77,6 +77,10 @@ + + biz.aQute.bnd + bnd-maven-plugin + org.apache.maven.plugins maven-compiler-plugin @@ -84,16 +88,6 @@ org.apache.maven.plugins maven-jar-plugin - - - - true - - - r2dbc.spi.test - - - org.apache.maven.plugins diff --git a/r2dbc-spi/pom.xml b/r2dbc-spi/pom.xml index d63f58b..9e54e9c 100644 --- a/r2dbc-spi/pom.xml +++ b/r2dbc-spi/pom.xml @@ -39,6 +39,16 @@ reactive-streams ${reactive-streams.version} + + biz.aQute.bnd + biz.aQute.bnd.annotation + ${bnd.version} + + + org.osgi + osgi.annotation + ${osgi.annotation.version} + com.google.code.findbugs jsr305 @@ -63,6 +73,15 @@ + + biz.aQute.bnd + bnd-maven-plugin + + + + org.apache.maven.plugins maven-compiler-plugin @@ -70,13 +89,6 @@ org.apache.maven.plugins maven-jar-plugin - - - - r2dbc.spi - - - org.apache.maven.plugins diff --git a/r2dbc-spi/src/main/java/io/r2dbc/spi/ConnectionFactoryProvider.java b/r2dbc-spi/src/main/java/io/r2dbc/spi/ConnectionFactoryProvider.java index 6a3dc89..d42cca7 100644 --- a/r2dbc-spi/src/main/java/io/r2dbc/spi/ConnectionFactoryProvider.java +++ b/r2dbc-spi/src/main/java/io/r2dbc/spi/ConnectionFactoryProvider.java @@ -16,8 +16,13 @@ package io.r2dbc.spi; +import static aQute.bnd.annotation.Cardinality.MULTIPLE; +import static aQute.bnd.annotation.Resolution.OPTIONAL; + import java.util.ServiceLoader; +import aQute.bnd.annotation.spi.ServiceConsumer; + /** * A Java Service interface for implementations to examine a collection of {@link ConnectionFactoryOptions} and optionally return an implementation of {@link ConnectionFactory}. *

{@link ConnectionFactoryProvider} implementations are typically discovered by {@link ConnectionFactories} from the class path using {@link ServiceLoader}. @@ -27,6 +32,15 @@ * @see ConnectionFactories * @see ServiceLoader */ + +@ServiceConsumer( + // This instance enables resolving a provider at _assembly_ without incurring a strict runtime + // dependency on Service Loader Mediator (SML) impl + cardinality = MULTIPLE, effective = "active", value = ConnectionFactoryProvider.class) +@ServiceConsumer( + // This instance enables SML to instrument ServiceLoader calls _if SML is present_ + // (without preventing the bundles from resolving if it is not) + cardinality = MULTIPLE, resolution = OPTIONAL, value = ConnectionFactoryProvider.class) public interface ConnectionFactoryProvider { /** From e1e7a98512dca7c54840e9963a9162e1bd4360c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raymond=20Aug=C3=A9?= Date: Tue, 5 Oct 2021 19:53:00 -0400 Subject: [PATCH 2/2] verify OSGi metadata using bnd-resolver-maven-plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raymond Augé --- pom.xml | 26 +++++++++++++++++ r2dbc-spi-test/pom.xml | 48 +++++++++++++++++++++++++++++++- r2dbc-spi-test/verifyOSGi.bndrun | 8 ++++++ r2dbc-spi/pom.xml | 16 +++++++++++ r2dbc-spi/verifyOSGi.bndrun | 8 ++++++ 5 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 r2dbc-spi-test/verifyOSGi.bndrun create mode 100644 r2dbc-spi/verifyOSGi.bndrun diff --git a/pom.xml b/pom.xml index 7964d22..90e3476 100644 --- a/pom.xml +++ b/pom.xml @@ -48,6 +48,7 @@ UTF-8 1.0.3 Dysprosium-SR12 + 5.2.6.RELEASE @@ -150,6 +151,31 @@ ]]> + + biz.aQute.bnd + bnd-resolver-maven-plugin + ${bnd.version} + + + integration-test + + resolve + + + + + + verifyOSGi.bndrun + + false + false + + compile + test + + false + + org.apache.maven.plugins maven-compiler-plugin diff --git a/r2dbc-spi-test/pom.xml b/r2dbc-spi-test/pom.xml index 5fb1ed2..ee35ba2 100644 --- a/r2dbc-spi-test/pom.xml +++ b/r2dbc-spi-test/pom.xml @@ -66,13 +66,55 @@ org.springframework spring-jdbc - 5.2.6.RELEASE + ${spring.version} com.google.code.findbugs jsr305 provided + + org.apache.aries.spifly + org.apache.aries.spifly.dynamic.framework.extension + 1.3.4 + test + + + org.apache.servicemix.bundles + org.apache.servicemix.bundles.spring-beans + ${spring.version}_1 + test + + + org.apache.servicemix.bundles + org.apache.servicemix.bundles.spring-context + ${spring.version}_1 + test + + + org.apache.servicemix.bundles + org.apache.servicemix.bundles.spring-core + ${spring.version}_1 + test + + + org.apache.servicemix.bundles + org.apache.servicemix.bundles.spring-jdbc + ${spring.version}_1 + test + + + org.apache.servicemix.bundles + org.apache.servicemix.bundles.spring-tx + ${spring.version}_1 + test + + + org.eclipse.platform + org.eclipse.osgi + 3.17.0 + test + @@ -81,6 +123,10 @@ biz.aQute.bnd bnd-maven-plugin + + biz.aQute.bnd + bnd-resolver-maven-plugin + org.apache.maven.plugins maven-compiler-plugin diff --git a/r2dbc-spi-test/verifyOSGi.bndrun b/r2dbc-spi-test/verifyOSGi.bndrun new file mode 100644 index 0000000..a5d6de5 --- /dev/null +++ b/r2dbc-spi-test/verifyOSGi.bndrun @@ -0,0 +1,8 @@ +-runfw: org.eclipse.osgi +-resolve.effective: resolve, active + +-runsystempackages: \ + sun.misc + +-runsystemcapabilities: \ + osgi.serviceloader;osgi.serviceloader=io.r2dbc.spi.ConnectionFactoryProvider diff --git a/r2dbc-spi/pom.xml b/r2dbc-spi/pom.xml index 9e54e9c..9320eef 100644 --- a/r2dbc-spi/pom.xml +++ b/r2dbc-spi/pom.xml @@ -69,6 +69,18 @@ assertj-core test + + org.apache.aries.spifly + org.apache.aries.spifly.dynamic.framework.extension + 1.3.4 + test + + + org.eclipse.platform + org.eclipse.osgi + 3.17.0 + test + @@ -82,6 +94,10 @@ ]]> + + biz.aQute.bnd + bnd-resolver-maven-plugin + org.apache.maven.plugins maven-compiler-plugin diff --git a/r2dbc-spi/verifyOSGi.bndrun b/r2dbc-spi/verifyOSGi.bndrun new file mode 100644 index 0000000..a5d6de5 --- /dev/null +++ b/r2dbc-spi/verifyOSGi.bndrun @@ -0,0 +1,8 @@ +-runfw: org.eclipse.osgi +-resolve.effective: resolve, active + +-runsystempackages: \ + sun.misc + +-runsystemcapabilities: \ + osgi.serviceloader;osgi.serviceloader=io.r2dbc.spi.ConnectionFactoryProvider