This is an automated email from the ASF dual-hosted git repository. ahuber pushed a commit to branch spring6 in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/spring6 by this push: new 79a226abc1 ISIS-3275: don't ship MOXy with commons (build fixes) 79a226abc1 is described below commit 79a226abc17dc02bdf74c6fb89a3004c38e41149 Author: Andi Huber <ahu...@apache.org> AuthorDate: Fri Dec 16 18:17:43 2022 +0100 ISIS-3275: don't ship MOXy with commons (build fixes) - as only used by RO clients that want to talk JSON - let clients pull in the dependencies --- commons/pom.xml | 19 ------------------ commons/src/main/java/module-info.java | 3 --- .../org/apache/causeway/commons/io/JsonUtils.java | 14 +++++++++++-- persistence/jpa/applib/pom.xml | 21 ++++++++++++++++++++ viewers/restfulobjects/client/pom.xml | 23 ++++++++++++++++++++++ .../restfulobjects/client/RestfulClient.java | 15 +++++++------- 6 files changed, 64 insertions(+), 31 deletions(-) diff --git a/commons/pom.xml b/commons/pom.xml index d2e6c1dbd1..c173cb2a2e 100644 --- a/commons/pom.xml +++ b/commons/pom.xml @@ -54,25 +54,6 @@ </build> <dependencies> - - <dependency> - <groupId>org.eclipse.persistence</groupId> - <artifactId>org.eclipse.persistence.moxy</artifactId> - <exclusions> - <exclusion> - <groupId>org.ow2.asm</groupId> - <artifactId>asm</artifactId> - </exclusion> - <exclusion> - <groupId>org.ow2.asm</groupId> - <artifactId>asm-tree</artifactId> - </exclusion> - <exclusion> - <groupId>org.ow2.asm</groupId> - <artifactId>asm-analysis</artifactId> - </exclusion> - </exclusions> - </dependency> <dependency> <groupId>com.fasterxml.woodstox</groupId> diff --git a/commons/src/main/java/module-info.java b/commons/src/main/java/module-info.java index 117828d4aa..9f46f0e78a 100644 --- a/commons/src/main/java/module-info.java +++ b/commons/src/main/java/module-info.java @@ -71,12 +71,9 @@ module org.apache.causeway.commons { requires transitive spring.beans; requires transitive spring.context; requires transitive spring.core; - //requires org.eclipse.persistence.moxy; - requires transitive jakarta.xml.bind; requires transitive jakarta.inject; requires jakarta.annotation; - requires org.eclipse.persistence.moxy; // JAXB JUnit test opens org.apache.causeway.commons.internal.resources to jakarta.xml.bind; diff --git a/commons/src/main/java/org/apache/causeway/commons/io/JsonUtils.java b/commons/src/main/java/org/apache/causeway/commons/io/JsonUtils.java index 00c9cb46eb..664e774b00 100644 --- a/commons/src/main/java/org/apache/causeway/commons/io/JsonUtils.java +++ b/commons/src/main/java/org/apache/causeway/commons/io/JsonUtils.java @@ -31,11 +31,13 @@ import com.fasterxml.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationModu import org.springframework.lang.Nullable; import org.apache.causeway.commons.functional.Try; +import org.apache.causeway.commons.internal.context._Context; import lombok.NonNull; import lombok.SneakyThrows; import lombok.val; import lombok.experimental.UtilityClass; +import lombok.extern.log4j.Log4j2; /** * Utilities to convert from and to JSON format. @@ -43,13 +45,21 @@ import lombok.experimental.UtilityClass; * @since 2.0 {@index} */ @UtilityClass +@Log4j2 public class JsonUtils { /** * Consumers of the framework may choose to use a different provider. */ - public Class<?> getPlatformDefaultJsonProviderForJaxb() { - return org.eclipse.persistence.jaxb.rs.MOXyJsonProvider.class; + public Optional<Class<?>> getPlatformDefaultJsonProviderForJaxb() { + return Try.call(()->_Context.loadClass("org.eclipse.persistence.jaxb.rs.MOXyJsonProvider")) + .ifFailure(cause-> + log.warn("This implementation of RestfulClient does require the class 'MOXyJsonProvider'" + + " on the class-path." + + " Are you missing a maven dependency?") + ) + .getValue() + .map(x->x); } @FunctionalInterface diff --git a/persistence/jpa/applib/pom.xml b/persistence/jpa/applib/pom.xml index 8b01f61a0c..594eada19e 100644 --- a/persistence/jpa/applib/pom.xml +++ b/persistence/jpa/applib/pom.xml @@ -88,6 +88,27 @@ <scope>provided</scope> </dependency> + <!-- TODO JPA API (providing compile dependency) --> + <dependency> + <groupId>org.eclipse.persistence</groupId> + <artifactId>org.eclipse.persistence.moxy</artifactId> + <version>4.0.0</version> + <exclusions> + <exclusion> + <groupId>org.ow2.asm</groupId> + <artifactId>asm</artifactId> + </exclusion> + <exclusion> + <groupId>org.ow2.asm</groupId> + <artifactId>asm-tree</artifactId> + </exclusion> + <exclusion> + <groupId>org.ow2.asm</groupId> + <artifactId>asm-analysis</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> diff --git a/viewers/restfulobjects/client/pom.xml b/viewers/restfulobjects/client/pom.xml index bbafbca024..9a5f9abe4b 100644 --- a/viewers/restfulobjects/client/pom.xml +++ b/viewers/restfulobjects/client/pom.xml @@ -53,6 +53,29 @@ <artifactId>parsson</artifactId> <version>1.1.1</version> </dependency> + + <dependency> + <groupId>org.eclipse.persistence</groupId> + <artifactId>org.eclipse.persistence.moxy</artifactId> + <exclusions> + <exclusion> + <groupId>org.eclipse.angus</groupId> + <artifactId>angus-activation</artifactId> + </exclusion> + <exclusion> + <groupId>org.ow2.asm</groupId> + <artifactId>asm</artifactId> + </exclusion> + <exclusion> + <groupId>org.ow2.asm</groupId> + <artifactId>asm-tree</artifactId> + </exclusion> + <exclusion> + <groupId>org.ow2.asm</groupId> + <artifactId>asm-analysis</artifactId> + </exclusion> + </exclusions> + </dependency> <!-- TEST DEPENDENCIES --> diff --git a/viewers/restfulobjects/client/src/main/java/org/apache/causeway/viewer/restfulobjects/client/RestfulClient.java b/viewers/restfulobjects/client/src/main/java/org/apache/causeway/viewer/restfulobjects/client/RestfulClient.java index 972dd5d78c..34b126465a 100644 --- a/viewers/restfulobjects/client/src/main/java/org/apache/causeway/viewer/restfulobjects/client/RestfulClient.java +++ b/viewers/restfulobjects/client/src/main/java/org/apache/causeway/viewer/restfulobjects/client/RestfulClient.java @@ -40,7 +40,6 @@ import org.apache.causeway.viewer.restfulobjects.client.auth.BasicAuthFilter.Cre import org.apache.causeway.viewer.restfulobjects.client.log.ClientConversationLogger; import lombok.NonNull; -import lombok.val; import lombok.extern.log4j.Log4j2; /** @@ -183,14 +182,16 @@ public class RestfulClient implements AutoCloseable { // -- HELPER FILTER private void registerDefaultJsonProviderForJaxb(final Optional<Class<?>> jsonProviderForJaxbOverride) { + jsonProviderForJaxbOverride + .or(JsonUtils::getPlatformDefaultJsonProviderForJaxb) + .ifPresent(jsonProviderForJaxb->{ - val jsonProviderForJaxb = jsonProviderForJaxbOverride - .orElseGet(JsonUtils::getPlatformDefaultJsonProviderForJaxb); + Try.run(()->client.register(jsonProviderForJaxb)) + .ifFailure(cause-> + log.error("Failed to register the JsonProviderForJaxb {} for the Restful Client to use." + + " Are you missing a Maven dependency?", jsonProviderForJaxb.getName(), cause)); - Try.run(()->client.register(jsonProviderForJaxb)) - .ifFailure(cause-> - log.error("Failed to register the JsonProviderForJaxb for the Restful Client to use." - + " Are you missing a Maven dependency?", cause)); + }); } private void registerBasicAuthFilter() {