Skip to content

Commit

Permalink
Migrate from Jakarta EE 8 to Jakarta EE 9
Browse files Browse the repository at this point in the history
  • Loading branch information
linghengqian committed Nov 1, 2024
1 parent f4001ba commit cd1496d
Show file tree
Hide file tree
Showing 439 changed files with 721 additions and 860 deletions.
2 changes: 1 addition & 1 deletion distribution/proxy/src/main/release-docs/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ EPL licenses
The following components are provided under the EPL License. See project link for details.
The text of each license is also included at licenses/LICENSE-[project].txt.

jakarta.transaction-api 1.3.3: https://github.com/jakartaee/transactions, EPL 2.0
jakarta.transaction-api 2.0.1: https://github.com/jakartaee/transactions, EPL 2.0
logback-classic 1.2.13: https://github.com/qos-ch/logback, EPL 1.0
logback-core 1.2.13: https://github.com/qos-ch/logback, EPL 1.0
mchange-commons-java 0.2.15: https://github.com/swaldman/mchange-commons-java, EPL 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ Apache ShardingSphere 提供 XA 事务,集成了 Narayana 的实现。
```xml
<properties>
<narayana.version>5.12.7.Final</narayana.version>
<jboss-transaction-spi.version>7.6.1.Final</jboss-transaction-spi.version>
<jboss-logging.version>3.2.1.Final</jboss-logging.version>
<jboss-logging.version>3.4.3.Final</jboss-logging.version>
</properties>

<dependency>
Expand All @@ -38,23 +37,18 @@ Apache ShardingSphere 提供 XA 事务,集成了 Narayana 的实现。
</dependency>
<dependency>
<groupId>org.jboss.narayana.jta</groupId>
<artifactId>jta</artifactId>
<artifactId>narayana-jta-jakarta</artifactId>
<version>${narayana.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.narayana.jts</groupId>
<artifactId>narayana-jts-integration</artifactId>
<version>${narayana.version}</version>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-transaction-spi</artifactId>
<version>${jboss-transaction-spi.version}</version>
<groupId>org.jboss.narayana.jts</groupId>
<artifactId>narayana-jts-integration-jakarta</artifactId>
<version>${narayana.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>${jboss-logging.version}</version>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>${jboss-logging.version}</version>
</dependency>
```
## 操作步骤
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ Introducing Maven dependency
```xml
<properties>
<narayana.version>5.12.7.Final</narayana.version>
<jboss-transaction-spi.version>7.6.1.Final</jboss-transaction-spi.version>
<jboss-logging.version>3.2.1.Final</jboss-logging.version>
<jboss-logging.version>3.4.3.Final</jboss-logging.version>
</properties>

<dependency>
Expand All @@ -38,23 +37,18 @@ Introducing Maven dependency
</dependency>
<dependency>
<groupId>org.jboss.narayana.jta</groupId>
<artifactId>jta</artifactId>
<artifactId>narayana-jta-jakarta</artifactId>
<version>${narayana.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.narayana.jts</groupId>
<artifactId>narayana-jts-integration</artifactId>
<version>${narayana.version}</version>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-transaction-spi</artifactId>
<version>${jboss-transaction-spi.version}</version>
<groupId>org.jboss.narayana.jts</groupId>
<artifactId>narayana-jts-integration-jakarta</artifactId>
<version>${narayana.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>${jboss-logging.version}</version>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>${jboss-logging.version}</version>
</dependency>
```
## Procedure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,9 @@ spring.datasource.url=jdbc:shardingsphere:classpath:xxx.yaml

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

## 针对 Spring Boot OSS 3 的处理

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

ShardingSphere 的 XA 分布式事务尚未在 Spring Boot OSS 3 上就绪,此限制同样适用于其他基于 Jakarta EE 9+ 的 Web Framework,如
Quarkus 3,Micronaut Framework 4 和 Helidon 3。

用户仅需要配置如下。

```xml
<project>
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc</artifactId>
<version>${shardingsphere.version}</version>
</dependency>
</dependencies>
</project>
```

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

ShardingSphere 的所有特性均可在 Spring Boot OSS 2 上使用,但低版本的 Spring Boot OSS 可能需要手动指定 SnakeYAML 的版本为 2.2 。
低版本的 Spring Boot OSS 可能需要手动指定 SnakeYAML 的版本为 2.2 。
这在 Maven 的 `pom.xml` 体现为如下内容。

```xml
Expand Down Expand Up @@ -95,3 +74,5 @@ ShardingSphere 的所有特性均可在 Spring Boot OSS 2 上使用,但低版
</dependencies>
</project>
```

此外,ShardingSphere 的 XA 分布式事务在 Spring Boot OSS 2.x 上无法集成于 Spring 自有注解。
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,9 @@ The YAML configuration file in 'spring.datasource.url' currently support in mult

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

## 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.

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.

Users only need to configure as follows.

```xml
<project>
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc</artifactId>
<version>${shardingsphere.version}</version>
</dependency>
</dependencies>
</project>
```

## 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
manually specifying version 2.2 for SnakeYAML.
Earlier versions of Spring Boot OSS may require manually specifying version 2.2 for SnakeYAML.
This is reflected in Maven's `pom.xml` as follows.

```xml
Expand Down Expand Up @@ -97,3 +75,5 @@ following things.
</dependencies>
</project>
```

In addition, ShardingSphere's XA distributed transactions cannot be integrated with Spring's own annotations on Spring Boot OSS 2.x.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ weight = 2

### jar 文件下载地址

- [arjuna-5.12.7.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/arjunacore/arjuna/5.12.7.Final/arjuna-5.12.7.Final.jar)
- [common-5.12.7.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/common/5.12.7.Final/common-5.12.7.Final.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.1.Final.jar](https://repo1.maven.org/maven2/org/jboss/jboss-transaction-spi/7.6.1.Final/jboss-transaction-spi-7.6.1.Final.jar)
- [jta-5.12.7.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/jta/jta/5.12.7.Final/jta-5.12.7.Final.jar)
- [narayana-jts-integration-5.12.7.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/jts/narayana-jts-integration/5.12.7.Final/narayana-jts-integration-5.12.7.Final.jar)
- [jboss-logging-3.4.3.Final.jar](https://repo1.maven.org/maven2/org/jboss/logging/jboss-logging/3.4.3.Final/jboss-logging-3.4.3.Final.jar)
- [jboss-transaction-spi-jakarta-7.6.1.Final.jar](https://repo1.maven.org/maven2/org/jboss/jboss-transaction-spi-jakarta/7.6.1.Final/jboss-transaction-spi-jakarta-7.6.1.Final.jar)
- [narayana-jta-jakarta-5.12.7.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/jta/narayana-jta-jakarta/5.12.7.Final/narayana-jta-jakarta-5.12.7.Final.jar)
- [narayana-jts-integration-jakarta-5.12.7.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/jts/narayana-jts-integration-jakarta/5.12.7.Final/narayana-jts-integration-jakarta-5.12.7.Final.jar)
- [shardingsphere-transaction-xa-narayana.jar](https://mvnrepository.com/artifact/org.apache.shardingsphere/shardingsphere-transaction-xa-narayana)

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

### jar file downloads

- [arjuna-5.12.7.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/arjunacore/arjuna/5.12.7.Final/arjuna-5.12.7.Final.jar)
- [common-5.12.7.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/common/5.12.7.Final/common-5.12.7.Final.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.1.Final.jar](https://repo1.maven.org/maven2/org/jboss/jboss-transaction-spi/7.6.1.Final/jboss-transaction-spi-7.6.1.Final.jar)
- [jta-5.12.7.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/jta/jta/5.12.7.Final/jta-5.12.7.Final.jar)
- [narayana-jts-integration-5.12.7.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/jts/narayana-jts-integration/5.12.7.Final/narayana-jts-integration-5.12.7.Final.jar)
- [jboss-logging-3.4.3.Final.jar](https://repo1.maven.org/maven2/org/jboss/logging/jboss-logging/3.4.3.Final/jboss-logging-3.4.3.Final.jar)
- [jboss-transaction-spi-jakarta-7.6.1.Final.jar](https://repo1.maven.org/maven2/org/jboss/jboss-transaction-spi-jakarta/7.6.1.Final/jboss-transaction-spi-jakarta-7.6.1.Final.jar)
- [narayana-jta-jakarta-5.12.7.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/jta/narayana-jta-jakarta/5.12.7.Final/narayana-jta-jakarta-5.12.7.Final.jar)
- [narayana-jts-integration-jakarta-5.12.7.Final.jar](https://repo1.maven.org/maven2/org/jboss/narayana/jts/narayana-jts-integration-jakarta/5.12.7.Final/narayana-jts-integration-jakarta-5.12.7.Final.jar)
- [shardingsphere-transaction-xa-narayana.jar](https://mvnrepository.com/artifact/org.apache.shardingsphere/shardingsphere-transaction-xa-narayana)

Please download the corresponding `shardingsphere-transaction-xa-narayana.jar` file according to the `proxy` version.
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
import org.apache.shardingsphere.transaction.xa.spi.XATransactionManagerProvider;

import javax.sql.DataSource;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.NotSupportedException;
import javax.transaction.RollbackException;
import javax.transaction.Status;
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
import jakarta.transaction.HeuristicMixedException;
import jakarta.transaction.HeuristicRollbackException;
import jakarta.transaction.NotSupportedException;
import jakarta.transaction.RollbackException;
import jakarta.transaction.Status;
import jakarta.transaction.SystemException;
import jakarta.transaction.TransactionManager;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.LinkedHashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@

package org.apache.shardingsphere.transaction.xa.jta.datasource;

import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import jakarta.transaction.RollbackException;
import jakarta.transaction.Synchronization;
import jakarta.transaction.SystemException;
import jakarta.transaction.Transaction;
import org.apache.shardingsphere.infra.database.core.spi.DatabaseTypedSPILoader;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.util.reflection.ReflectionUtils;
import org.apache.shardingsphere.transaction.xa.jta.connection.XAConnectionWrapper;
import org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
Expand All @@ -29,10 +33,6 @@
import javax.sql.DataSource;
import javax.sql.XAConnection;
import javax.sql.XADataSource;
import javax.transaction.RollbackException;
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.atomikos.jdbc.AtomikosDataSourceBean;
import com.zaxxer.hikari.HikariDataSource;
import jakarta.transaction.Transaction;
import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
Expand All @@ -31,7 +32,6 @@
import org.mockito.internal.configuration.plugins.Plugins;

import javax.sql.DataSource;
import javax.transaction.Transaction;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.LinkedHashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

package org.apache.shardingsphere.transaction.xa.fixture;

import jakarta.transaction.TransactionManager;
import org.apache.shardingsphere.transaction.xa.spi.SingleXAResource;
import org.apache.shardingsphere.transaction.xa.spi.XATransactionManagerProvider;

import javax.sql.XADataSource;
import javax.transaction.TransactionManager;

public final class FixtureXATransactionManagerProvider implements XATransactionManagerProvider {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@

import com.atomikos.jdbc.AtomikosDataSourceBean;
import com.zaxxer.hikari.HikariDataSource;
import jakarta.transaction.RollbackException;
import jakarta.transaction.Synchronization;
import jakarta.transaction.SystemException;
import jakarta.transaction.Transaction;
import jakarta.transaction.TransactionManager;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.transaction.xa.fixture.DataSourceUtils;
Expand All @@ -34,11 +39,6 @@

import javax.sql.DataSource;
import javax.sql.XADataSource;
import javax.transaction.RollbackException;
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import java.sql.Connection;
import java.sql.SQLException;

Expand Down
17 changes: 5 additions & 12 deletions kernel/transaction/type/xa/provider/atomikos/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@
<artifactId>shardingsphere-transaction-xa-atomikos</artifactId>
<name>${project.artifactId}</name>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.atomikos</groupId>
<artifactId>transactions-essentials</artifactId>
<version>${atomikos.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
Expand All @@ -48,14 +36,19 @@
<dependency>
<groupId>com.atomikos</groupId>
<artifactId>transactions</artifactId>
<version>${atomikos.version}</version>
</dependency>
<dependency>
<groupId>com.atomikos</groupId>
<artifactId>transactions-jta</artifactId>
<version>${atomikos.version}</version>
<classifier>jakarta</classifier>
</dependency>
<dependency>
<groupId>com.atomikos</groupId>
<artifactId>transactions-jdbc</artifactId>
<version>${atomikos.version}</version>
<classifier>jakarta</classifier>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
import com.atomikos.icatch.config.UserTransactionService;
import com.atomikos.icatch.config.UserTransactionServiceImp;
import com.atomikos.icatch.jta.UserTransactionManager;
import jakarta.transaction.RollbackException;
import jakarta.transaction.SystemException;
import lombok.Getter;
import lombok.SneakyThrows;
import org.apache.shardingsphere.transaction.xa.spi.SingleXAResource;
import org.apache.shardingsphere.transaction.xa.spi.XATransactionManagerProvider;

import javax.sql.XADataSource;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;

/**
* Atomikos XA transaction manager provider.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

import com.atomikos.icatch.config.UserTransactionService;
import com.atomikos.icatch.jta.UserTransactionManager;
import jakarta.transaction.RollbackException;
import jakarta.transaction.SystemException;
import jakarta.transaction.Transaction;
import org.apache.shardingsphere.transaction.xa.spi.SingleXAResource;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -28,9 +31,6 @@
import org.mockito.junit.jupiter.MockitoExtension;

import javax.sql.XADataSource;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
import javax.transaction.Transaction;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
Expand Down
Loading

0 comments on commit cd1496d

Please sign in to comment.