You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by ah...@apache.org on 2023/02/28 10:34:01 UTC
[causeway] branch spring6 updated (228f99664f -> 9ff172c4c3)
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a change to branch spring6
in repository https://gitbox.apache.org/repos/asf/causeway.git
from 228f99664f CAUSEWAY-3304: [Commons] Code Quality Improvements for 2.0.0 Release
add 15d7311f15 CAUSEWAY-3304: JaxbUtils: don't use JAXBContext#newInstance
add b3ae8fb231 CAUSEWAY-3304: purge the old JaxbUtil class
add 9aec521493 CAUSEWAY-3222: regen. ref. index
new 9ff172c4c3 CAUSEWAY-3304: [Commons] Code Quality Improvements for 2.0.0 Release
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../services/iactnlayer/InteractionService.adoc | 2 +-
.../modules/applib/pages/index/util/JaxbUtil.adoc | 16 --
.../commons/pages/index/functional/Railway.adoc | 64 +++----
.../pages/index/functional/ThrowingConsumer.adoc | 100 ++++++++++
.../pages/index/functional/ThrowingRunnable.adoc} | 11 +-
.../pages/index/functional/ThrowingSupplier.adoc | 100 ++++++++++
.../commons/pages/index/functional/Try.adoc | 173 +++++++++++++----
.../pages/index/io/DataPeer.adoc} | 13 +-
.../modules/commons/pages/index/io/DataSink.adoc | 37 +++-
.../modules/commons/pages/index/io/DataSource.adoc | 205 +++++++++++++++++++--
.../modules/commons/pages/index/io/FileUtils.adoc | 161 ++++++++++++++++
.../modules/commons/pages/index/io/JaxbUtils.adoc | 33 ----
.../applib/dtos/ScalarValueDtoV2.adoc | 3 +
.../client/ActionParameterListBuilder.adoc | 13 ++
.../index/restfulobjects/client/RestfulClient.adoc | 11 ++
...ntentNegotiationServiceOrgApacheCausewayV2.adoc | 1 -
.../org/apache/causeway/applib/util/JaxbUtil.java | 97 ----------
commons/src/main/java/module-info.java | 1 +
.../org/apache/causeway/commons/io/JaxbUtils.java | 77 +++++---
.../internal/resources/XmlRoundTripTest.java | 30 +--
.../apache/causeway/commons/io/JaxbUtilsTest.java | 10 +-
core/adoc/modules/_overview/pages/about.adoc | 4 +-
22 files changed, 850 insertions(+), 312 deletions(-)
delete mode 100644 antora/components/refguide-index/modules/applib/pages/index/util/JaxbUtil.adoc
create mode 100644 antora/components/refguide-index/modules/commons/pages/index/functional/ThrowingConsumer.adoc
copy antora/components/refguide-index/modules/{applib/pages/index/CausewayModuleApplibChangeAndExecutionLoggers.adoc => commons/pages/index/functional/ThrowingRunnable.adoc} (74%)
create mode 100644 antora/components/refguide-index/modules/commons/pages/index/functional/ThrowingSupplier.adoc
copy antora/components/refguide-index/modules/{applib/pages/index/annotation/Bounding.adoc => commons/pages/index/io/DataPeer.adoc} (80%)
create mode 100644 antora/components/refguide-index/modules/commons/pages/index/io/FileUtils.adoc
delete mode 100644 api/applib/src/main/java/org/apache/causeway/applib/util/JaxbUtil.java
[causeway] 01/01: CAUSEWAY-3304: [Commons] Code Quality Improvements for 2.0.0 Release
Posted by ah...@apache.org.
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/causeway.git
commit 9ff172c4c395f8b09664ab1f869faa88ccfdf784
Merge: 228f99664f 9aec521493
Author: Andi Huber <ah...@apache.org>
AuthorDate: Tue Feb 28 11:33:56 2023 +0100
CAUSEWAY-3304: [Commons] Code Quality Improvements for 2.0.0 Release
.../services/iactnlayer/InteractionService.adoc | 2 +-
.../commons/pages/index/functional/Railway.adoc | 64 +++----
.../pages/index/functional/ThrowingConsumer.adoc | 100 ++++++++++
.../pages/index/functional/ThrowingRunnable.adoc} | 13 +-
.../pages/index/functional/ThrowingSupplier.adoc | 100 ++++++++++
.../commons/pages/index/functional/Try.adoc | 173 +++++++++++++----
.../pages/index/io/DataPeer.adoc} | 12 +-
.../modules/commons/pages/index/io/DataSink.adoc | 37 +++-
.../modules/commons/pages/index/io/DataSource.adoc | 205 +++++++++++++++++++--
.../modules/commons/pages/index/io/FileUtils.adoc | 161 ++++++++++++++++
.../modules/commons/pages/index/io/JaxbUtils.adoc | 33 ----
.../applib/dtos/ScalarValueDtoV2.adoc | 3 +
.../client/ActionParameterListBuilder.adoc | 13 ++
.../index/restfulobjects/client/RestfulClient.adoc | 11 ++
...ntentNegotiationServiceOrgApacheCausewayV2.adoc | 1 -
.../org/apache/causeway/applib/util/JaxbUtil.java | 97 ----------
commons/src/main/java/module-info.java | 1 +
.../org/apache/causeway/commons/io/JaxbUtils.java | 77 +++++---
.../internal/resources/XmlRoundTripTest.java | 30 +--
.../apache/causeway/commons/io/JaxbUtilsTest.java | 10 +-
core/adoc/modules/_overview/pages/about.adoc | 4 +-
21 files changed, 850 insertions(+), 297 deletions(-)
diff --cc commons/src/main/java/module-info.java
index f6b422e3ba,be3c4b56be..440302f374
--- a/commons/src/main/java/module-info.java
+++ b/commons/src/main/java/module-info.java
@@@ -71,12 -72,12 +71,13 @@@ module org.apache.causeway.commons
requires transitive spring.beans;
requires transitive spring.context;
requires transitive spring.core;
- requires java.inject;
- requires java.annotation;
+ requires transitive jakarta.xml.bind;
+ requires transitive jakarta.inject;
+ requires jakarta.annotation;
+ requires com.sun.xml.bind;
- requires org.apache.causeway.core.privileged;
- opens org.apache.causeway.commons.internal.resources to java.xml.bind, com.sun.xml.bind; // JUnit test
- opens org.apache.causeway.commons.io to java.xml.bind, com.sun.xml.bind;
+ // JAXB JUnit test
+ opens org.apache.causeway.commons.internal.resources to jakarta.xml.bind;
+ opens org.apache.causeway.commons.io to jakarta.xml.bind;
}
diff --cc commons/src/main/java/org/apache/causeway/commons/io/JaxbUtils.java
index 9412f24c13,f049a9b690..d194323b7f
--- a/commons/src/main/java/org/apache/causeway/commons/io/JaxbUtils.java
+++ b/commons/src/main/java/org/apache/causeway/commons/io/JaxbUtils.java
@@@ -20,6 -20,10 +20,7 @@@ package org.apache.causeway.commons.io
import java.io.InputStream;
import java.io.OutputStream;
-import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.MethodType;
+ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@@ -27,13 -31,14 +28,15 @@@ import java.util.function.Consumer
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBContextFactory;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
import javax.xml.namespace.QName;
+import jakarta.xml.bind.JAXBContext;
++import jakarta.xml.bind.JAXBContextFactory;
+import jakarta.xml.bind.JAXBElement;
++import jakarta.xml.bind.JAXBException;
+import jakarta.xml.bind.Marshaller;
+import jakarta.xml.bind.Unmarshaller;
+
import org.springframework.lang.Nullable;
import org.apache.causeway.commons.functional.Try;
@@@ -57,33 -61,26 +59,19 @@@ import lombok.experimental.UtilityClass
/**
* Utilities to convert from and to JAXB-XML format.
+ * @implNote instead of using {@link JAXBContext#newInstance(Class...)},
+ * which does lookup the JaxbContextFactory on each call,
+ * and which - depending on system-properties - could change during the lifetime of an application,
- * we rather utilize the com.sun.xml.bind.v2.ContextFactory directly.
++ * we rather utilize the org.glassfish.jaxb.runtime.v2.JAXBContextFactory directly.
*
* @since 2.0 {@index}
*/
@UtilityClass
public class JaxbUtils {
- /** uses given context factory as the new platform default */
- public void setDefaultJAXBContextFactory(final Class<?> jaxbContextFactoryClass, final boolean force) {
- if(force
- || System.getProperty(JAXBContext.JAXB_CONTEXT_FACTORY)==null) {
- if(jaxbContextFactoryClass!=null) {
- System.setProperty(JAXBContext.JAXB_CONTEXT_FACTORY, jaxbContextFactoryClass.getName());
- } else {
- System.clearProperty(JAXBContext.JAXB_CONTEXT_FACTORY);
- }
- }
- }
-
- /** uses MOXy */
- public void useMoxy() {
- //setDefaultJAXBContextFactory(org.eclipse.persistence.jaxb.JAXBContextFactory.class, true);
- }
-
- /** clears the system property override */
- public static void usePlatformDefault() {
- setDefaultJAXBContextFactory(null, true);
- }
- private final static Class<?> JAXB_CONTEXT_FACTORY = com.sun.xml.bind.v2.ContextFactory.class;
++ private final static jakarta.xml.bind.JAXBContextFactory JAXB_CONTEXT_FACTORY =
++ new org.glassfish.jaxb.runtime.v2.JAXBContextFactory();
+ private final static Map<String,Object> JAXB_CONTEXT_FACTORY_PROPS = Collections.<String,Object>emptyMap();
- private final static MethodHandle JAXB_CONTEXT_FACTORY_METHOD_HANDLE = jaxbContextFactoryMethodHandle();
-
- @SneakyThrows
- private static MethodHandle jaxbContextFactoryMethodHandle() {
- return MethodHandles.publicLookup()
- .findStatic(JAXB_CONTEXT_FACTORY, "createContext",
- MethodType.methodType(JAXBContext.class, Class[].class, Map.class));
- }
@Data @Builder
public static class JaxbOptions {
@@@ -302,7 -299,7 +290,7 @@@
@SneakyThrows
private static <T> JAXBContext contextOf(final Class<?> ... classesToBeBound) {
try {
- return JAXBContext.newInstance(classesToBeBound);
- return (JAXBContext) JAXB_CONTEXT_FACTORY_METHOD_HANDLE.invoke(open(classesToBeBound), JAXB_CONTEXT_FACTORY_PROPS);
++ return JAXB_CONTEXT_FACTORY.createContext(open(classesToBeBound), JAXB_CONTEXT_FACTORY_PROPS);
} catch (Exception e) {
val msg = String.format("obtaining JAXBContext for classes (to be bound) {%s}", _NullSafe.stream(classesToBeBound)
.map(Class::getName)
diff --cc commons/src/test/java/org/apache/causeway/commons/internal/resources/XmlRoundTripTest.java
index 1f720913e7,392aaa1ae0..1812bad86d
--- a/commons/src/test/java/org/apache/causeway/commons/internal/resources/XmlRoundTripTest.java
+++ b/commons/src/test/java/org/apache/causeway/commons/internal/resources/XmlRoundTripTest.java
@@@ -18,13 -18,11 +18,11 @@@
*/
package org.apache.causeway.commons.internal.resources;
- import jakarta.xml.bind.JAXBContext;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
+import jakarta.xml.bind.annotation.XmlAccessType;
+import jakarta.xml.bind.annotation.XmlAccessorType;
+import jakarta.xml.bind.annotation.XmlElement;
+import jakarta.xml.bind.annotation.XmlType;
- import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;