Skip to content

Commit

Permalink
JAXP extension quarkusio#12129
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalaga committed Sep 16, 2020
1 parent ebfeffc commit 4be0ac5
Show file tree
Hide file tree
Showing 16 changed files with 521 additions and 19 deletions.
10 changes: 10 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,16 @@
<artifactId>quarkus-jaxb-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jaxp</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jaxp-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jackson</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/jaxb/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jaxp-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jaxb</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,6 @@ class JaxbProcessor {
private static final List<Class<?>> JAXB_REFLECTIVE_CLASSES = Arrays.asList(
XmlAccessOrder.class);

private static final List<String> JAXB_SERIALIZERS = Arrays.asList(
"html",
"text",
"xml",
"unknown");

private static final DotName XML_ROOT_ELEMENT = DotName.createSimple(XmlRootElement.class.getName());
private static final DotName XML_TYPE = DotName.createSimple(XmlType.class.getName());
private static final DotName XML_REGISTRY = DotName.createSimple(XmlRegistry.class.getName());
Expand Down Expand Up @@ -193,10 +187,6 @@ void registerClasses(
BuildProducer<NativeImageSystemPropertyBuildItem> nativeImageProps,
BuildProducer<ServiceProviderBuildItem> providerItem) {

addReflectiveClass(false, false, "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
addReflectiveClass(false, false, "com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl");
addReflectiveClass(false, false, "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
addReflectiveClass(false, false, "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
addReflectiveClass(true, false, "com.sun.xml.bind.v2.ContextFactory");
addReflectiveClass(true, false, "com.sun.xml.internal.bind.v2.ContextFactory");

Expand All @@ -207,11 +197,6 @@ void registerClasses(

addResourceBundle("javax.xml.bind.Messages");
addResourceBundle("javax.xml.bind.helpers.Messages");
addResourceBundle("com.sun.org.apache.xml.internal.serializer.utils.SerializerMessages");
addResourceBundle("com.sun.org.apache.xml.internal.res.XMLErrorResources");
addResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages");
addResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages");
addResourceBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message");

nativeImageProps
.produce(new NativeImageSystemPropertyBuildItem("com.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize", "true"));
Expand All @@ -220,10 +205,6 @@ void registerClasses(
.map(Class::getName)
.forEach(className -> addReflectiveClass(true, false, className));

JAXB_SERIALIZERS.stream()
.map(s -> "com/sun/org/apache/xml/internal/serializer/output_" + s + ".properties")
.forEach(this::addResource);

providerItem
.produce(new ServiceProviderBuildItem(JAXBContext.class.getName(), "com.sun.xml.bind.v2.ContextFactory"));
}
Expand Down
4 changes: 4 additions & 0 deletions extensions/jaxb/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jaxp</artifactId>
</dependency>
<!-- Don't rely on the JDK impl to be present as it's not present in JDK 11+ -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
Expand Down
44 changes: 44 additions & 0 deletions extensions/jaxp/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>quarkus-jaxp-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-jaxp-deployment</artifactId>
<name>Quarkus - JAXP - Deployment</name>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jaxp</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package io.quarkus.jaxp.deployment;

import java.util.stream.Stream;

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBundleBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;

class JaxpProcessor {

@BuildStep
void reflectiveClasses(BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
reflectiveClass.produce(new ReflectiveClassBuildItem(false, false,
"com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl",
"com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl",
"com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl",
"com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl",
"com.sun.org.apache.xerces.internal.parsers.SAXParser",
"com.sun.org.apache.xml.internal.utils.FastStringBuffer"));

reflectiveClass.produce(new ReflectiveClassBuildItem(true, false,
"com.sun.xml.internal.stream.XMLInputFactoryImpl",
"com.sun.xml.internal.stream.XMLOutputFactoryImpl",
"com.sun.org.apache.xpath.internal.functions.FuncNot",
"com.sun.org.apache.xerces.internal.impl.dv.xs.SchemaDVFactoryImpl",
"javax.xml.namespace.QName"));
}

@BuildStep
void resourceBundles(BuildProducer<NativeImageResourceBundleBuildItem> resourceBundle) {
Stream.of(
"com.sun.org.apache.xml.internal.serializer.utils.SerializerMessages",
"com.sun.org.apache.xml.internal.res.XMLErrorResources",
"com.sun.org.apache.xerces.internal.impl.msg.SAXMessages",
"com.sun.org.apache.xerces.internal.impl.msg.XMLMessages",
"com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages",
"com.sun.org.apache.xerces.internal.impl.xpath.regex.message")
.map(NativeImageResourceBundleBuildItem::new)
.forEach(resourceBundle::produce);
}

@BuildStep
void resources(BuildProducer<NativeImageResourceBuildItem> resource) {

Stream.of(
"html",
"text",
"xml",
"unknown")
.map(s -> "com/sun/org/apache/xml/internal/serializer/output_" + s + ".properties")
.map(NativeImageResourceBuildItem::new)
.forEach(resource::produce);

}

}
21 changes: 21 additions & 0 deletions extensions/jaxp/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>quarkus-build-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
<relativePath>../../build-parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-jaxp-parent</artifactId>
<name>Quarkus - JAXP</name>
<packaging>pom</packaging>
<modules>
<module>deployment</module>
<module>runtime</module>
</modules>

</project>
43 changes: 43 additions & 0 deletions extensions/jaxp/runtime/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>quarkus-jaxp-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-jaxp</artifactId>
<name>Quarkus - JAXP - Runtime</name>
<description>Java API for XML Processing</description>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bootstrap-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
name: "JAXP"
metadata:
categories:
- "xml"
status: "stable"
1 change: 1 addition & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<module>arc</module>
<module>scheduler</module>
<module>quartz</module>
<module>jaxp</module>

<!-- Configuration -->
<module>config-yaml</module>
Expand Down
53 changes: 53 additions & 0 deletions integration-tests/jaxp/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
= Read me
:config-file: microprofile-config.properties
:toc:

This module is testing the configuration and integration aspects of JPA;
for example it covers reading configuration properties from the Quarkus config files as an alternative to the `persistence.xml`.

All integration tests in this module use `H2`; other databases are being tested from other integration test modules.

== How to run tests from the IDE

They should just work: no preparation needed for this module.

== Documentation

See the `docs` section and the Hibernate guide.

== Design questions

* Is it appropriate to prioritize `persistence.xml` when it is present and ignore otherwise (i.e. disable automatic PU generation when `persistence.xml` is there
** [SOLVED] we go for not allowing both
* Is it appropriate to select `JTA` as the transaction type strategy
* Is it appropriate to detect the dialect from the driver
** [SOLVED] we start from that and can add runtime refinement of the dialect based on JDBC metadata and enlist all dialects of a family to avoid DCE
* Which properties are the most useful for Hibernate ORM?
** see section below
* Do we have a pass through of properties under something like `quarkus.hibernate`
** [SOLVED] we start with that
* which prefix do we want? `quarkus.hibernate`, `hibernate`, `jpa` etc
** what about `javax.persistence properties`?
** [SOLVED] we start with `quarkus.hibernate`

=== List of properties

I am doing a first pass on the properties and I want to propose the following properties (and nothing else):

* `hibernate.dialect`
* `hibernate.show_sql` (and then `hibernate.format_sql` ?)
* should show_sql not do System.out but rather a proper log
* `javax.persistence.schema-generation.database.action`

Anything else?

I would force the following:

* `javax.persistence.sharedCache.mode` to yes
* `javax.persistence.sql-load-script-source` set to a default file name

Questions do we need:

* `javax.persistence.transactionType`


Loading

0 comments on commit 4be0ac5

Please sign in to comment.