Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes use of JAXB API via jackson-dataformat-xml #29384

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions distribution/proxy/src/main/release-docs/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,13 @@ The text of each license is the standard Apache 2.0 license.
httpcore5-h2 5.1.3: https://hc.apache.org/httpcomponents-core-5.1.x, Apache 2.0
httpcore5 5.1.3: https://hc.apache.org/httpcomponents-core-5.1.x, Apache 2.0
j2objc-annotations 1.3 https://github.com/google/j2objc/, Apache 2.0
jackson-annotations 2.14.0: http://github.com/FasterXML/jackson, Apache 2.0
jackson-core 2.14.0: http://github.com/FasterXML/jackson, Apache 2.0
jackson-databind 2.14.0: http://github.com/FasterXML/jackson, Apache 2.0
jackson-dataformat-yaml 2.14.0: http://github.com/FasterXML/jackson, Apache 2.0
jackson-datatype-jsr310 2.14.0: http://github.com/FasterXML/jackson, Apache 2.0
jackson-annotations 2.16.0: http://github.com/FasterXML/jackson, Apache 2.0
jackson-core 2.16.0: http://github.com/FasterXML/jackson, Apache 2.0
jackson-databind 2.16.0: http://github.com/FasterXML/jackson, Apache 2.0
jackson-dataformat-xml 2.16.0: https://github.com/FasterXML/jackson-dataformat-xml, Apache 2.0
jackson-dataformat-yaml 2.16.0: http://github.com/FasterXML/jackson, Apache 2.0
jackson-datatype-jdk8 2.16.0: http://github.com/FasterXML/jackson-modules-java8, Apache 2.0
jackson-datatype-jsr310 2.16.0: http://github.com/FasterXML/jackson, Apache 2.0
jcl-over-slf4j 1.7.36: https://github.com/qos-ch/slf4j, Apache 2.0
jetcd-api 0.7.6: https://github.com/etcd-io/jetcd, Apache 2.0
jetcd-common 0.7.6: https://github.com/etcd-io/jetcd, Apache 2.0
Expand Down Expand Up @@ -336,17 +338,6 @@ The text of each license is also included at licenses/LICENSE-[project].txt.
jts-io-common 1.19.0: https://github.com/locationtech/jts, EDL 1.0
jts-core 1.19.0: https://github.com/locationtech/jts, EDL 1.0

========================================================================
EDL licenses
========================================================================

The following components are provided under the EDL License. See project link for details.
The text of each license is also included at licenses/LICENSE-[project].txt.

jakarta.activation-api 1.2.2: https://github.com/jakartaee/jaf-api, EDL 1.0
jakarta.xml.bind-api 2.3.3: https://github.com/jakartaee/jaxb-api, EDL 1.0
jaxb-runtime 2.3.9 https://eclipse-ee4j.github.io/jaxb-ri/, EDL 1.0

========================================================================
EPL licenses
========================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@ spring.datasource.url=jdbc:shardingsphere:classpath:xxx.yaml

直接使用该数据源;或者将 ShardingSphereDataSource 配置在 JPA、Hibernate、MyBatis 等 ORM 框架中配合使用。

## 针对 Spring Boot OSS 3 的特殊处理
## 针对 Spring Boot OSS 3 的处理

Spring Boot OSS 3 对 Jakarta EE 和 Java 17 进行了 “大爆炸” 升级,涉及大量复杂情况。

对于正在使用 Java EE 8 API 及其实现的 ShardingSphere JDBC 而言,如果用户希望在 Spring Boot OSS 3 等基于 Jakarta EE 9+ API 的 Web
Framework 上使用 ShardingSphere JDBC,则需要引入 Java EE 8 的 JAXB 的实现。

这在 Maven 的 `pom.xml` 体现为如下内容。你也可以使用其他的 JAXB API 的实现。此配置同样适用于其他基于 Jakarta EE 的 Web Framework,如
ShardingSphere 的 XA 分布式事务尚未在 Spring Boot OSS 3 上就绪,此限制同样适用于其他基于 Jakarta EE 9+ 的 Web Framework,如
Quarkus 3,Micronaut Framework 4 和 Helidon 3。

用户仅需要配置如下。

```xml
<project>
<dependencies>
Expand All @@ -53,17 +52,10 @@ Quarkus 3,Micronaut Framework 4 和 Helidon 3。
<artifactId>shardingsphere-jdbc-core</artifactId>
<version>${shardingsphere.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.9</version>
</dependency>
</dependencies>
</project>
```

此外,ShardingSphere 的 XA 分布式事务尚未在 Spring Boot OSS 3 上就绪。

## 针对低版本的 Spring Boot OSS 2 的特殊处理

ShardingSphere 的所有特性均可在 Spring Boot OSS 2 上使用,但低版本的 Spring Boot OSS 可能需要手动指定 SnakeYAML 的版本为 2.2 。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ The YAML configuration file in 'spring.datasource.url' currently support in two

Use this data source directly; or configure ShardingSphereDataSource to be used in conjunction with ORM frameworks such as JPA, Hibernate, and MyBatis.

## Special handling for Spring Boot OSS 3
## Handling for Spring Boot OSS 3

Spring Boot OSS 3 has made a "big bang" upgrade to Jakarta EE and Java 17, with all complications involved.

For ShardingSphere JDBC that is using the Java EE 8 API and its implementation, if you want to use ShardingSphere JDBC
on a Jakarta EE 9+ API-based web framework such as Spring Boot OSS 3, you need to introduce a JAXB implementation of
Java EE 8.
ShardingSphere's XA distributed transactions are not yet ready on Spring Boot OSS 3. This limitation also applies to other
Jakarta EE 9+ based Web Frameworks, such as Quarkus 3, Micronaut Framework 4 and Helidon 3.

This is reflected in Maven's `pom.xml` as follows. You can also use other JAXB API implementations. This configuration
also applies to other Jakarta EE-based Web Frameworks, such as Quarkus 3, Micronaut Framework 4 and Helidon 3.
Users only need to configure as follows.

```xml
<project>
Expand All @@ -54,17 +52,10 @@ also applies to other Jakarta EE-based Web Frameworks, such as Quarkus 3, Micron
<artifactId>shardingsphere-jdbc-core</artifactId>
<version>${shardingsphere.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.9</version>
</dependency>
</dependencies>
</project>
```

In addition, ShardingSphere's XA distributed transactions are not yet ready on Spring Boot OSS 3.

## Special handling for earlier versions of Spring Boot OSS 2

All features of ShardingSphere are available on Spring Boot OSS 2, but earlier versions of Spring Boot OSS may require
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,12 @@ weight = 2

- [arjuna-5.12.4.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/arjunacore/arjuna/5.12.4.Final/arjuna-5.12.4.Final.jar)
- [common-5.12.4.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/common/5.12.4.Final/common-5.12.4.Final.jar)
- [istack-commons-runtime-3.0.12.jar](https://repo1.maven.org/maven2/com/sun/istack/istack-commons-runtime/3.0.12/istack-commons-runtime-3.0.12.jar)
- [jakarta.activation-api-1.2.2.jar](https://repo1.maven.org/maven2/jakarta/activation/jakarta.activation-api/1.2.2/jakarta.activation-api-1.2.2.jar)
- [jakarta.xml.bind-api-2.3.3.jar](https://repo1.maven.org/maven2/jakarta/xml/bind/jakarta.xml.bind-api/2.3.3/jakarta.xml.bind-api-2.3.3.jar)
- [jaxb-runtime-2.3.9.jar](https://repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-runtime/2.3.9/jaxb-runtime-2.3.9.jar)
- [jboss-connector-api_1.7_spec-1.0.0.Final.jar](https://repo1.maven.org/maven2/org/jboss/spec/javax/resource/jboss-connector-api_1.7_spec/1.0.0.Final/jboss-connector-api_1.7_spec-1.0.0.Final.jar)
- [jboss-logging-3.2.1.Final.jar](https://repo1.maven.org/maven2/org/jboss/logging/jboss-logging/3.2.1.Final/jboss-logging-3.2.1.Final.jar)
- [jboss-transaction-api_1.2_spec-1.0.0.Alpha3.jar](https://repo1.maven.org/maven2/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.0.0.Alpha3/jboss-transaction-api_1.2_spec-1.0.0.Alpha3.jar)
- [jboss-transaction-spi-7.6.0.Final.jar](https://repo1.maven.org/maven2/org/jboss/jboss-transaction-spi/7.6.0.Final/jboss-transaction-spi-7.6.0.Final.jar)
- [jta-5.12.4.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/jta/jta/5.12.4.Final/jta-5.12.4.Final.jar)
- [narayana-jts-integration-5.12.4.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/jts/narayana-jts-integration/5.12.4.Final/narayana-jts-integration-5.12.4.Final.jar)
- [shardingsphere-transaction-xa-narayana.jar](https://mvnrepository.com/artifact/org.apache.shardingsphere/shardingsphere-transaction-xa-narayana)
- [txw2-2.3.9.jar](https://repo1.maven.org/maven2/org/glassfish/jaxb/txw2/2.3.9/txw2-2.3.9.jar)

请根据 `proxy` 版本下载对应 `shardingsphere-transaction-xa-narayana.jar` 文件。
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,12 @@ Adding Narayana dependencies requires downloading the following jar files and ad

- [arjuna-5.12.4.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/arjunacore/arjuna/5.12.4.Final/arjuna-5.12.4.Final.jar)
- [common-5.12.4.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/common/5.12.4.Final/common-5.12.4.Final.jar)
- [istack-commons-runtime-3.0.12.jar](https://repo1.maven.org/maven2/com/sun/istack/istack-commons-runtime/3.0.12/istack-commons-runtime-3.0.12.jar)
- [jakarta.activation-api-1.2.2.jar](https://repo1.maven.org/maven2/jakarta/activation/jakarta.activation-api/1.2.2/jakarta.activation-api-1.2.2.jar)
- [jakarta.xml.bind-api-2.3.3.jar](https://repo1.maven.org/maven2/jakarta/xml/bind/jakarta.xml.bind-api/2.3.3/jakarta.xml.bind-api-2.3.3.jar)
- [jaxb-runtime-2.3.9.jar](https://repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-runtime/2.3.9/jaxb-runtime-2.3.9.jar)
- [jboss-connector-api_1.7_spec-1.0.0.Final.jar](https://repo1.maven.org/maven2/org/jboss/spec/javax/resource/jboss-connector-api_1.7_spec/1.0.0.Final/jboss-connector-api_1.7_spec-1.0.0.Final.jar)
- [jboss-logging-3.2.1.Final.jar](https://repo1.maven.org/maven2/org/jboss/logging/jboss-logging/3.2.1.Final/jboss-logging-3.2.1.Final.jar)
- [jboss-transaction-api_1.2_spec-1.0.0.Alpha3.jar](https://repo1.maven.org/maven2/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.0.0.Alpha3/jboss-transaction-api_1.2_spec-1.0.0.Alpha3.jar)
- [jboss-transaction-spi-7.6.0.Final.jar](https://repo1.maven.org/maven2/org/jboss/jboss-transaction-spi/7.6.0.Final/jboss-transaction-spi-7.6.0.Final.jar)
- [jta-5.12.4.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/jta/jta/5.12.4.Final/jta-5.12.4.Final.jar)
- [narayana-jts-integration-5.12.4.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/jts/narayana-jts-integration/5.12.4.Final/narayana-jts-integration-5.12.4.Final.jar)
- [shardingsphere-transaction-xa-narayana.jar](https://mvnrepository.com/artifact/org.apache.shardingsphere/shardingsphere-transaction-xa-narayana)
- [txw2-2.3.9.jar](https://repo1.maven.org/maven2/org/glassfish/jaxb/txw2/2.3.9/txw2-2.3.9.jar)

Please download the corresponding `shardingsphere-transaction-xa-narayana.jar` file according to the `proxy` version.

This file was deleted.

5 changes: 4 additions & 1 deletion infra/util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
</dependency>

<dependency>
Expand Down
14 changes: 2 additions & 12 deletions kernel/sql-federation/optimizer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.junit.jupiter.params.provider.ArgumentsProvider;
import org.junit.jupiter.params.provider.ArgumentsSource;

import javax.xml.bind.JAXBException;
import java.io.IOException;
import java.sql.Types;
import java.util.Arrays;
Expand Down Expand Up @@ -252,7 +251,7 @@ void assertCompile(final TestCase testcase) {

private static class TestCaseArgumentsProvider implements ArgumentsProvider {

@SneakyThrows({IOException.class, JAXBException.class})
@SneakyThrows(IOException.class)
@Override
public Stream<? extends Arguments> provideArguments(final ExtensionContext extensionContext) {
return TestCasesLoader.getInstance().generate().stream().map(Arguments::of);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,21 @@

package org.apache.shardingsphere.sqlfederation.optimizer.it;

import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import lombok.Getter;
import lombok.Setter;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;

/**
* JAXB definition of test case.
*/
@XmlAccessorType(XmlAccessType.FIELD)
@Getter
@Setter
public final class TestCase {

@XmlAttribute(name = "sql")
@JacksonXmlProperty(localName = "sql", isAttribute = true)
private String sql;

@XmlElement(name = "assertion")
@JacksonXmlProperty(localName = "assertion")
private TestCaseAssertion assertion;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@

package org.apache.shardingsphere.sqlfederation.optimizer.it;

import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import lombok.Getter;
import lombok.Setter;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;

/**
* JAXB definition of test case assertion.
*/
@XmlAccessorType(XmlAccessType.FIELD)
@Getter
@Setter
public final class TestCaseAssertion {

@XmlAttribute(name = "expected-result")
@JacksonXmlProperty(localName = "expected-result", isAttribute = true)
private String expectedResult;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@

package org.apache.shardingsphere.sqlfederation.optimizer.it;

import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import lombok.Getter;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Collection;
import java.util.LinkedList;

/**
* JAXB definition of test cases.
*/
@XmlRootElement(name = "test-cases")
@JacksonXmlRootElement(localName = "test-cases")
@Getter
public final class TestCases {

@XmlElement(name = "test-case")
@JacksonXmlProperty(localName = "test-case")
private final Collection<TestCase> testCases = new LinkedList<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

package org.apache.shardingsphere.sqlfederation.optimizer.it;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;

import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
Expand All @@ -33,6 +34,8 @@ public final class TestCasesLoader {

private static final TestCasesLoader INSTANCE = new TestCasesLoader();

private static final ObjectMapper XML_MAPPER = XmlMapper.builder().defaultUseWrapper(false).build();

/**
* Get singleton instance.
*
Expand All @@ -47,9 +50,8 @@ public static TestCasesLoader getInstance() {
*
* @return collection of test cases
* @throws IOException exception for read file.
* @throws JAXBException exception for parse xml file.
*/
public Collection<TestCase> generate() throws IOException, JAXBException {
public Collection<TestCase> generate() throws IOException {
Collection<TestCase> result = new LinkedList<>();
URL queryCaseUrl = Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource("cases/federation-query-sql-cases.xml"));
URL deleteCaseUrl = Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource("cases/federation-delete-sql-cases.xml"));
Expand All @@ -58,9 +60,9 @@ public Collection<TestCase> generate() throws IOException, JAXBException {
return result;
}

private Collection<TestCase> loadTestCase(final URL url) throws IOException, JAXBException {
private Collection<TestCase> loadTestCase(final URL url) throws IOException {
try (FileReader reader = new FileReader(url.getFile())) {
TestCases testCases = (TestCases) JAXBContext.newInstance(TestCases.class).createUnmarshaller().unmarshal(reader);
TestCases testCases = XML_MAPPER.readValue(reader, TestCases.class);
return testCases.getTestCases();
}
}
Expand Down
13 changes: 0 additions & 13 deletions kernel/transaction/type/xa/provider/narayana/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,5 @@
<version>${jboss-logging.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
</dependency>
</dependencies>
</project>
12 changes: 2 additions & 10 deletions mode/type/standalone/repository/provider/jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,8 @@
</dependency>

<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
Expand Down
Loading