This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 261edbf52e4 Merge XADataSourceDefinition and DialectTransactionOption
(#37044)
261edbf52e4 is described below
commit 261edbf52e45d1d7e0a8e975d25371c3a669f53e
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Nov 8 22:10:43 2025 +0800
Merge XADataSourceDefinition and DialectTransactionOption (#37044)
---
.../database/metadata/DialectDatabaseMetaData.java | 3 +-
.../transaction/DialectTransactionOption.java | 4 +++
.../database/FirebirdDatabaseMetaData.java | 3 +-
.../h2/metadata/database/H2DatabaseMetaData.java | 9 +++++
.../database/MariaDBDatabaseMetaData.java} | 33 +++++++++---------
...adata.database.metadata.DialectDatabaseMetaData | 18 ++++++++++
.../metadata/database/MySQLDatabaseMetaData.java | 4 ++-
.../database/OpenGaussDatabaseMetaData.java | 3 +-
.../metadata/database/OracleDatabaseMetaData.java | 8 +++++
.../database/PostgreSQLDatabaseMetaData.java | 3 +-
.../database/SQLServerDatabaseMetaData.java | 9 +++++
.../graalvm-native-image/_index.cn.md | 2 +-
.../graalvm-native-image/_index.en.md | 2 +-
.../xa/jta/datasource/XATransactionDataSource.java | 6 ++--
.../properties/XADataSourceDefinition.java | 37 --------------------
.../dialect/FirebirdXADataSourceDefinition.java | 39 ----------------------
.../dialect/H2XADataSourceDefinition.java | 39 ----------------------
.../dialect/MariaDBXADataSourceDefinition.java | 39 ----------------------
.../dialect/MySQLXADataSourceDefinition.java | 39 ----------------------
.../dialect/OpenGaussXADataSourceDefinition.java | 39 ----------------------
.../dialect/OracleXADataSourceDefinition.java | 39 ----------------------
.../dialect/PostgreSQLXADataSourceDefinition.java | 39 ----------------------
.../dialect/SQLServerXADataSourceDefinition.java | 39 ----------------------
.../jta/datasource/swapper/DataSourceSwapper.java | 11 +++---
.../exception/XADataSourceInitializeException.java | 6 ++--
...ta.datasource.properties.XADataSourceDefinition | 25 --------------
.../transaction/xa/fixture/DataSourceUtils.java | 7 ++--
.../dialect/FirebirdXAConnectionWrapperTest.java | 6 ++--
.../dialect/H2XAConnectionWrapperTest.java | 6 ++--
.../dialect/MariaDBXAConnectionWrapperTest.java | 6 ++--
.../dialect/MySQLXAConnectionWrapperTest.java | 6 ++--
.../dialect/OpenGaussXAConnectionWrapperTest.java | 6 ++--
.../dialect/OracleXAConnectionWrapperTest.java | 6 ++--
.../dialect/PostgreSQLXAConnectionWrapperTest.java | 6 ++--
.../FirebirdXADataSourceDefinitionTest.java | 33 ------------------
.../dialect/H2XADataSourceDefinitionTest.java | 33 ------------------
.../dialect/MariaDBXADataSourceDefinitionTest.java | 34 -------------------
.../dialect/MySQLXADataSourceDefinitionTest.java | 33 ------------------
.../OpenGaussXADataSourceDefinitionTest.java | 33 ------------------
.../dialect/OracleXADataSourceDefinitionTest.java | 33 ------------------
.../PostgreSQLXADataSourceDefinitionTest.java | 33 ------------------
.../SQLServerXADataSourceDefinitionTest.java | 33 ------------------
.../datasource/swapper/DataSourceSwapperTest.java | 23 ++++---------
43 files changed, 132 insertions(+), 703 deletions(-)
diff --git
a/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/metadata/DialectDatabaseMetaData.java
b/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/metadata/DialectDatabaseMetaData.java
index c1007018f12..0f6d8091a42 100644
---
a/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/metadata/DialectDatabaseMetaData.java
+++
b/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/metadata/DialectDatabaseMetaData.java
@@ -39,6 +39,7 @@ import
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPI;
import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
import java.sql.Connection;
+import java.util.Collections;
import java.util.Optional;
/**
@@ -129,7 +130,7 @@ public interface DialectDatabaseMetaData extends
DatabaseTypedSPI {
* @return transaction option
*/
default DialectTransactionOption getTransactionOption() {
- return new DialectTransactionOption(false, false, false, false, true,
Connection.TRANSACTION_READ_COMMITTED, false, false);
+ return new DialectTransactionOption(false, false, false, false, true,
Connection.TRANSACTION_READ_COMMITTED, false, false, Collections.emptyList());
}
/**
diff --git
a/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/metadata/option/transaction/DialectTransactionOption.java
b/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/metadata/option/transaction/DialectTransactionOption.java
index e9172d17aff..419e9bd8232 100644
---
a/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/metadata/option/transaction/DialectTransactionOption.java
+++
b/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/metadata/option/transaction/DialectTransactionOption.java
@@ -20,6 +20,8 @@ package
org.apache.shardingsphere.database.connector.core.metadata.database.meta
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import java.util.Collection;
+
/**
* Dialect transaction option.
*/
@@ -43,4 +45,6 @@ public final class DialectTransactionOption {
private final boolean isReturnRollbackStatementWhenCommitFailed;
private final boolean isAllowCommitAndRollbackOnlyWhenTransactionFailed;
+
+ private final Collection<String> xaDriverClassNames;
}
diff --git
a/database/connector/dialect/firebird/src/main/java/org/apache/shardingsphere/database/connector/firebird/metadata/database/FirebirdDatabaseMetaData.java
b/database/connector/dialect/firebird/src/main/java/org/apache/shardingsphere/database/connector/firebird/metadata/database/FirebirdDatabaseMetaData.java
index 52f9ec3864f..7fa17ddc0ae 100644
---
a/database/connector/dialect/firebird/src/main/java/org/apache/shardingsphere/database/connector/firebird/metadata/database/FirebirdDatabaseMetaData.java
+++
b/database/connector/dialect/firebird/src/main/java/org/apache/shardingsphere/database/connector/firebird/metadata/database/FirebirdDatabaseMetaData.java
@@ -27,6 +27,7 @@ import
org.apache.shardingsphere.database.connector.core.metadata.database.metad
import
org.apache.shardingsphere.database.connector.firebird.metadata.database.option.FirebirdSchemaOption;
import java.sql.Connection;
+import java.util.Collections;
/**
* Database metadata of Firebird.
@@ -55,7 +56,7 @@ public final class FirebirdDatabaseMetaData implements
DialectDatabaseMetaData {
@Override
public DialectTransactionOption getTransactionOption() {
- return new DialectTransactionOption(false, true, false, false, true,
Connection.TRANSACTION_READ_COMMITTED, false, true);
+ return new DialectTransactionOption(false, true, false, false, true,
Connection.TRANSACTION_READ_COMMITTED, false, true,
Collections.singleton("org.firebirdsql.ds.FBXADataSource"));
}
@Override
diff --git
a/database/connector/dialect/h2/src/main/java/org/apache/shardingsphere/database/connector/h2/metadata/database/H2DatabaseMetaData.java
b/database/connector/dialect/h2/src/main/java/org/apache/shardingsphere/database/connector/h2/metadata/database/H2DatabaseMetaData.java
index d9a72976f55..9340a8eec9b 100644
---
a/database/connector/dialect/h2/src/main/java/org/apache/shardingsphere/database/connector/h2/metadata/database/H2DatabaseMetaData.java
+++
b/database/connector/dialect/h2/src/main/java/org/apache/shardingsphere/database/connector/h2/metadata/database/H2DatabaseMetaData.java
@@ -21,6 +21,10 @@ import
org.apache.shardingsphere.database.connector.core.metadata.database.enums
import
org.apache.shardingsphere.database.connector.core.metadata.database.enums.QuoteCharacter;
import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.DialectDatabaseMetaData;
import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.IdentifierPatternType;
+import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.transaction.DialectTransactionOption;
+
+import java.sql.Connection;
+import java.util.Collections;
/**
* Database meta data of H2.
@@ -42,6 +46,11 @@ public final class H2DatabaseMetaData implements
DialectDatabaseMetaData {
return NullsOrderType.LOW;
}
+ @Override
+ public DialectTransactionOption getTransactionOption() {
+ return new DialectTransactionOption(false, false, false, false, true,
Connection.TRANSACTION_READ_COMMITTED, false, false,
Collections.singleton("org.h2.jdbcx.JdbcDataSource"));
+ }
+
@Override
public String getDatabaseType() {
return "H2";
diff --git
a/database/connector/dialect/mysql/src/main/java/org/apache/shardingsphere/database/connector/mysql/metadata/database/MySQLDatabaseMetaData.java
b/database/connector/dialect/mariadb/src/main/java/org/apache/shardingsphere/database/connector/mariadb/metadata/database/MariaDBDatabaseMetaData.java
similarity index 78%
copy from
database/connector/dialect/mysql/src/main/java/org/apache/shardingsphere/database/connector/mysql/metadata/database/MySQLDatabaseMetaData.java
copy to
database/connector/dialect/mariadb/src/main/java/org/apache/shardingsphere/database/connector/mariadb/metadata/database/MariaDBDatabaseMetaData.java
index 602dc0c6303..7975f27d59e 100644
---
a/database/connector/dialect/mysql/src/main/java/org/apache/shardingsphere/database/connector/mysql/metadata/database/MySQLDatabaseMetaData.java
+++
b/database/connector/dialect/mariadb/src/main/java/org/apache/shardingsphere/database/connector/mariadb/metadata/database/MariaDBDatabaseMetaData.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.database.connector.mysql.metadata.database;
+package org.apache.shardingsphere.database.connector.mariadb.metadata.database;
import
org.apache.shardingsphere.database.connector.core.metadata.database.enums.NullsOrderType;
import
org.apache.shardingsphere.database.connector.core.metadata.database.enums.QuoteCharacter;
@@ -28,67 +28,70 @@ import
org.apache.shardingsphere.database.connector.core.metadata.database.metad
import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.keygen.DialectGeneratedKeyOption;
import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.transaction.DialectTransactionOption;
import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.version.DialectProtocolVersionOption;
-import
org.apache.shardingsphere.database.connector.mysql.metadata.database.option.MySQLDataTypeOption;
+import
org.apache.shardingsphere.database.connector.mysql.metadata.database.MySQLDatabaseMetaData;
import java.sql.Connection;
+import java.util.Collections;
/**
- * Database meta data of MySQL.
+ * Database meta data of MariaDB.
*/
-public final class MySQLDatabaseMetaData implements DialectDatabaseMetaData {
+public final class MariaDBDatabaseMetaData implements DialectDatabaseMetaData {
+
+ private final DialectDatabaseMetaData delegate = new
MySQLDatabaseMetaData();
@Override
public QuoteCharacter getQuoteCharacter() {
- return QuoteCharacter.BACK_QUOTE;
+ return delegate.getQuoteCharacter();
}
@Override
public IdentifierPatternType getIdentifierPatternType() {
- return IdentifierPatternType.KEEP_ORIGIN;
+ return delegate.getIdentifierPatternType();
}
@Override
public NullsOrderType getDefaultNullsOrderType() {
- return NullsOrderType.LOW;
+ return delegate.getDefaultNullsOrderType();
}
@Override
public DialectDataTypeOption getDataTypeOption() {
- return new MySQLDataTypeOption();
+ return delegate.getDataTypeOption();
}
@Override
public DialectColumnOption getColumnOption() {
- return new DialectColumnOption(false);
+ return delegate.getColumnOption();
}
@Override
public DialectConnectionOption getConnectionOption() {
- return new DialectConnectionOption(true, true);
+ return delegate.getConnectionOption();
}
@Override
public DialectTransactionOption getTransactionOption() {
- return new DialectTransactionOption(false, false, true, false, true,
Connection.TRANSACTION_REPEATABLE_READ, false, false);
+ return new DialectTransactionOption(false, false, true, false, true,
Connection.TRANSACTION_REPEATABLE_READ, false, false,
Collections.singleton("org.mariadb.jdbc.MariaDbDataSource"));
}
@Override
public DialectJoinOption getJoinOption() {
- return new DialectJoinOption(true, true);
+ return delegate.getJoinOption();
}
@Override
public DialectGeneratedKeyOption getGeneratedKeyOption() {
- return new DialectGeneratedKeyOption(true);
+ return delegate.getGeneratedKeyOption();
}
@Override
public DialectProtocolVersionOption getProtocolVersionOption() {
- return new DialectProtocolVersionOption("5.7.22");
+ return delegate.getProtocolVersionOption();
}
@Override
public String getDatabaseType() {
- return "MySQL";
+ return "MariaDB";
}
}
diff --git
a/database/connector/dialect/mariadb/src/main/resources/META-INF/services/org.apache.shardingsphere.database.connector.core.metadata.database.metadata.DialectDatabaseMetaData
b/database/connector/dialect/mariadb/src/main/resources/META-INF/services/org.apache.shardingsphere.database.connector.core.metadata.database.metadata.DialectDatabaseMetaData
new file mode 100644
index 00000000000..965b5edd532
--- /dev/null
+++
b/database/connector/dialect/mariadb/src/main/resources/META-INF/services/org.apache.shardingsphere.database.connector.core.metadata.database.metadata.DialectDatabaseMetaData
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.shardingsphere.database.connector.mariadb.metadata.database.MariaDBDatabaseMetaData
diff --git
a/database/connector/dialect/mysql/src/main/java/org/apache/shardingsphere/database/connector/mysql/metadata/database/MySQLDatabaseMetaData.java
b/database/connector/dialect/mysql/src/main/java/org/apache/shardingsphere/database/connector/mysql/metadata/database/MySQLDatabaseMetaData.java
index 602dc0c6303..b3653d0c957 100644
---
a/database/connector/dialect/mysql/src/main/java/org/apache/shardingsphere/database/connector/mysql/metadata/database/MySQLDatabaseMetaData.java
+++
b/database/connector/dialect/mysql/src/main/java/org/apache/shardingsphere/database/connector/mysql/metadata/database/MySQLDatabaseMetaData.java
@@ -31,6 +31,7 @@ import
org.apache.shardingsphere.database.connector.core.metadata.database.metad
import
org.apache.shardingsphere.database.connector.mysql.metadata.database.option.MySQLDataTypeOption;
import java.sql.Connection;
+import java.util.Arrays;
/**
* Database meta data of MySQL.
@@ -69,7 +70,8 @@ public final class MySQLDatabaseMetaData implements
DialectDatabaseMetaData {
@Override
public DialectTransactionOption getTransactionOption() {
- return new DialectTransactionOption(false, false, true, false, true,
Connection.TRANSACTION_REPEATABLE_READ, false, false);
+ return new DialectTransactionOption(false, false, true, false, true,
Connection.TRANSACTION_REPEATABLE_READ, false, false,
+
Arrays.asList("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource",
"com.mysql.cj.jdbc.MysqlXADataSource"));
}
@Override
diff --git
a/database/connector/dialect/opengauss/src/main/java/org/apache/shardingsphere/database/connector/opengauss/metadata/database/OpenGaussDatabaseMetaData.java
b/database/connector/dialect/opengauss/src/main/java/org/apache/shardingsphere/database/connector/opengauss/metadata/database/OpenGaussDatabaseMetaData.java
index ca13b4b31ed..f81dd99ecad 100644
---
a/database/connector/dialect/opengauss/src/main/java/org/apache/shardingsphere/database/connector/opengauss/metadata/database/OpenGaussDatabaseMetaData.java
+++
b/database/connector/dialect/opengauss/src/main/java/org/apache/shardingsphere/database/connector/opengauss/metadata/database/OpenGaussDatabaseMetaData.java
@@ -32,6 +32,7 @@ import
org.apache.shardingsphere.database.connector.opengauss.metadata.database.
import
org.apache.shardingsphere.database.connector.opengauss.metadata.database.option.OpenGaussSchemaOption;
import java.sql.Connection;
+import java.util.Collections;
import java.util.Optional;
/**
@@ -76,7 +77,7 @@ public final class OpenGaussDatabaseMetaData implements
DialectDatabaseMetaData
@Override
public DialectTransactionOption getTransactionOption() {
- return new DialectTransactionOption(true, false, false, true, false,
Connection.TRANSACTION_READ_COMMITTED, true, true);
+ return new DialectTransactionOption(true, false, false, true, false,
Connection.TRANSACTION_READ_COMMITTED, true, true,
Collections.singleton("org.opengauss.xa.PGXADataSource"));
}
@Override
diff --git
a/database/connector/dialect/oracle/src/main/java/org/apache/shardingsphere/database/connector/oracle/metadata/database/OracleDatabaseMetaData.java
b/database/connector/dialect/oracle/src/main/java/org/apache/shardingsphere/database/connector/oracle/metadata/database/OracleDatabaseMetaData.java
index 6f89693e633..6cf685b618b 100644
---
a/database/connector/dialect/oracle/src/main/java/org/apache/shardingsphere/database/connector/oracle/metadata/database/OracleDatabaseMetaData.java
+++
b/database/connector/dialect/oracle/src/main/java/org/apache/shardingsphere/database/connector/oracle/metadata/database/OracleDatabaseMetaData.java
@@ -27,9 +27,12 @@ import
org.apache.shardingsphere.database.connector.core.metadata.database.metad
import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.index.DialectIndexOption;
import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.pagination.DialectPaginationOption;
import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.schema.DialectSchemaOption;
+import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.transaction.DialectTransactionOption;
import
org.apache.shardingsphere.database.connector.oracle.metadata.database.option.OracleDataTypeOption;
import
org.apache.shardingsphere.database.connector.oracle.metadata.database.option.OracleSchemaOption;
+import java.sql.Connection;
+import java.util.Collections;
import java.util.Optional;
/**
@@ -72,6 +75,11 @@ public final class OracleDatabaseMetaData implements
DialectDatabaseMetaData {
return new DialectConnectionOption(true, false);
}
+ @Override
+ public DialectTransactionOption getTransactionOption() {
+ return new DialectTransactionOption(false, false, false, false, true,
Connection.TRANSACTION_READ_COMMITTED, false, false,
Collections.singleton("oracle.jdbc.xa.client.OracleXADataSource"));
+ }
+
@Override
public DialectPaginationOption getPaginationOption() {
return new DialectPaginationOption(true, "ROWNUM", false);
diff --git
a/database/connector/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/connector/postgresql/metadata/database/PostgreSQLDatabaseMetaData.java
b/database/connector/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/connector/postgresql/metadata/database/PostgreSQLDatabaseMetaData.java
index 6397aaa380d..dff34a05d69 100644
---
a/database/connector/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/connector/postgresql/metadata/database/PostgreSQLDatabaseMetaData.java
+++
b/database/connector/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/connector/postgresql/metadata/database/PostgreSQLDatabaseMetaData.java
@@ -30,6 +30,7 @@ import
org.apache.shardingsphere.database.connector.postgresql.metadata.database
import
org.apache.shardingsphere.database.connector.postgresql.metadata.database.option.PostgreSQLSchemaOption;
import java.sql.Connection;
+import java.util.Collections;
/**
* Database meta data of PostgreSQL.
@@ -68,7 +69,7 @@ public final class PostgreSQLDatabaseMetaData implements
DialectDatabaseMetaData
@Override
public DialectTransactionOption getTransactionOption() {
- return new DialectTransactionOption(false, false, false, true, false,
Connection.TRANSACTION_READ_COMMITTED, true, true);
+ return new DialectTransactionOption(false, false, false, true, false,
Connection.TRANSACTION_READ_COMMITTED, true, true,
Collections.singleton("org.postgresql.xa.PGXADataSource"));
}
@Override
diff --git
a/database/connector/dialect/sqlserver/src/main/java/org/apache/shardingsphere/database/connector/sql92/sqlserver/metadata/database/SQLServerDatabaseMetaData.java
b/database/connector/dialect/sqlserver/src/main/java/org/apache/shardingsphere/database/connector/sql92/sqlserver/metadata/database/SQLServerDatabaseMetaData.java
index fca40d57328..3c614adf0ce 100644
---
a/database/connector/dialect/sqlserver/src/main/java/org/apache/shardingsphere/database/connector/sql92/sqlserver/metadata/database/SQLServerDatabaseMetaData.java
+++
b/database/connector/dialect/sqlserver/src/main/java/org/apache/shardingsphere/database/connector/sql92/sqlserver/metadata/database/SQLServerDatabaseMetaData.java
@@ -25,7 +25,10 @@ import
org.apache.shardingsphere.database.connector.core.metadata.database.metad
import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.pagination.DialectPaginationOption;
import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.schema.DefaultSchemaOption;
import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.schema.DialectSchemaOption;
+import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.transaction.DialectTransactionOption;
+import java.sql.Connection;
+import java.util.Collections;
import java.util.Optional;
/**
@@ -53,6 +56,12 @@ public final class SQLServerDatabaseMetaData implements
DialectDatabaseMetaData
return new DefaultSchemaOption(false, "dbo");
}
+ @Override
+ public DialectTransactionOption getTransactionOption() {
+ return new DialectTransactionOption(false, false, false, false, true,
Connection.TRANSACTION_READ_COMMITTED, false, false,
+
Collections.singleton("com.microsoft.sqlserver.jdbc.SQLServerXADataSource"));
+ }
+
@Override
public DialectPaginationOption getPaginationOption() {
return new DialectPaginationOption(true, "ROW_NUMBER", true);
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.cn.md
index cef64fe5a8b..101232d35cc 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.cn.md
@@ -251,7 +251,7 @@ Caused by: java.io.UnsupportedEncodingException: Codepage
Cp1252 is not supporte
5. 讨论在 ShardingSphere JDBC 的 GraalVM Native Image 下使用 XA
分布式事务的所需步骤,则需要引入额外的已知前提,
-
`org.apache.shardingsphere.transaction.xa.jta.datasource.swapper.DataSourceSwapper#loadXADataSource(String)`
会通过 `java.lang.Class#getDeclaredConstructors` 实例化各数据库驱动的
`javax.sql.XADataSource` 实现类。
- - 各数据库驱动的 `javax.sql.XADataSource` 实现类的全类名通过实现
`org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition`
的 SPI,来存入 ShardingSphere 的元数据。
+ - 各数据库驱动的 `javax.sql.XADataSource` 实现类的全类名通过实现
`org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.transaction.DialectTransactionOption`
的 SPI,来存入 ShardingSphere 的元数据。
在 GraalVM Native Image 内部,这实际上要求定义第三方依赖的 GraalVM Reachability Metadata,而
ShardingSphere 自身仅为 `com.h2database:h2` 提供对应的 GraalVM Reachability Metadata。
`com.mysql:mysql-connector-j` 等其他数据库驱动的 GraalVM Reachability Metadata 应自行定义,
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.en.md
index 6b269a5c9e4..2dc3ef32426 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.en.md
@@ -260,7 +260,7 @@ Caused by: java.io.UnsupportedEncodingException: Codepage
Cp1252 is not supporte
5. To discuss the steps required to use XA distributed transactions under the
GraalVM Native Image of ShardingSphere JDBC,
additional known prerequisites need to be introduced,
-
`org.apache.shardingsphere.transaction.xa.jta.datasource.swapper.DataSourceSwapper#loadXADataSource(String)`
will instantiate the `javax.sql.XADataSource` implementation class of each
database driver through `java.lang.Class#getDeclaredConstructors`.
- - The full class name of the `javax.sql.XADataSource` implementation class
of each database driver is stored in the metadata of ShardingSphere by
implementing the SPI of
`org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition`.
+ - The full class name of the `javax.sql.XADataSource` implementation class
of each database driver is stored in the metadata of ShardingSphere by
implementing the SPI of
`org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.transaction.DialectTransactionOption`.
In the GraalVM Native Image, this actually requires the definition of the
GraalVM Reachability Metadata of the third-party dependencies,
while ShardingSphere itself only provides the corresponding GraalVM
Reachability Metadata for `com.h2database:h2`.
diff --git
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/XATransactionDataSource.java
b/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/XATransactionDataSource.java
index 609bd95ecf8..7d5d8ac269e 100644
---
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/XATransactionDataSource.java
+++
b/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/XATransactionDataSource.java
@@ -17,11 +17,12 @@
package org.apache.shardingsphere.transaction.xa.jta.datasource;
+import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.transaction.DialectTransactionOption;
import
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.database.connector.core.type.DatabaseTypeRegistry;
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;
import
org.apache.shardingsphere.transaction.xa.jta.datasource.swapper.DataSourceSwapper;
import org.apache.shardingsphere.transaction.xa.spi.SingleXAResource;
import
org.apache.shardingsphere.transaction.xa.spi.XATransactionManagerProvider;
@@ -69,7 +70,8 @@ public final class XATransactionDataSource implements
AutoCloseable {
this.resourceName = resourceName;
this.dataSource = dataSource;
if
(!CONTAINER_DATASOURCE_NAMES.contains(dataSource.getClass().getSimpleName())) {
- xaDataSource = new
DataSourceSwapper(DatabaseTypedSPILoader.getService(XADataSourceDefinition.class,
databaseType)).swap(dataSource);
+ DialectTransactionOption transactionOption = new
DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData().getTransactionOption();
+ xaDataSource = new DataSourceSwapper(databaseType,
transactionOption.getXaDriverClassNames()).swap(dataSource);
xaConnectionWrapper =
DatabaseTypedSPILoader.getService(XAConnectionWrapper.class, databaseType);
this.xaTransactionManagerProvider = xaTransactionManagerProvider;
xaTransactionManagerProvider.registerRecoveryResource(resourceName,
xaDataSource);
diff --git
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/XADataSourceDefinition.java
b/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/XADataSourceDefinition.java
deleted file mode 100644
index f4b39879970..00000000000
---
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/XADataSourceDefinition.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.transaction.xa.jta.datasource.properties;
-
-import org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPI;
-import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
-
-import java.util.Collection;
-
-/**
- * XA data source definition.
- */
-@SingletonSPI
-public interface XADataSourceDefinition extends DatabaseTypedSPI {
-
- /**
- * Get XA driver class names.
- *
- * @return XA driver class names
- */
- Collection<String> getXADriverClassNames();
-}
diff --git
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/FirebirdXADataSourceDefinition.java
b/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/FirebirdXADataSourceDefinition.java
deleted file mode 100644
index c6e2f81d851..00000000000
---
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/FirebirdXADataSourceDefinition.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect;
-
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
-
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * XA data source definition for Firebird.
- */
-public final class FirebirdXADataSourceDefinition implements
XADataSourceDefinition {
-
- @Override
- public Collection<String> getXADriverClassNames() {
- return Collections.singletonList("org.firebirdsql.ds.FBXADataSource");
- }
-
- @Override
- public String getDatabaseType() {
- return "Firebird";
- }
-}
diff --git
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/H2XADataSourceDefinition.java
b/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/H2XADataSourceDefinition.java
deleted file mode 100644
index 26fe03f6f2a..00000000000
---
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/H2XADataSourceDefinition.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect;
-
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
-
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * XA data source definition for H2.
- */
-public final class H2XADataSourceDefinition implements XADataSourceDefinition {
-
- @Override
- public Collection<String> getXADriverClassNames() {
- return Collections.singletonList("org.h2.jdbcx.JdbcDataSource");
- }
-
- @Override
- public String getDatabaseType() {
- return "H2";
- }
-}
diff --git
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/MariaDBXADataSourceDefinition.java
b/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/MariaDBXADataSourceDefinition.java
deleted file mode 100644
index 0a0b5608235..00000000000
---
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/MariaDBXADataSourceDefinition.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect;
-
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
-
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * XA data source definition for MariaDB.
- */
-public final class MariaDBXADataSourceDefinition implements
XADataSourceDefinition {
-
- @Override
- public Collection<String> getXADriverClassNames() {
- return Collections.singletonList("org.mariadb.jdbc.MariaDbDataSource");
- }
-
- @Override
- public String getDatabaseType() {
- return "MariaDB";
- }
-}
diff --git
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/MySQLXADataSourceDefinition.java
b/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/MySQLXADataSourceDefinition.java
deleted file mode 100644
index ef18a3dd301..00000000000
---
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/MySQLXADataSourceDefinition.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect;
-
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-/**
- * XA data source definition for MySQL.
- */
-public final class MySQLXADataSourceDefinition implements
XADataSourceDefinition {
-
- @Override
- public Collection<String> getXADriverClassNames() {
- return
Arrays.asList("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource",
"com.mysql.cj.jdbc.MysqlXADataSource");
- }
-
- @Override
- public String getDatabaseType() {
- return "MySQL";
- }
-}
diff --git
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/OpenGaussXADataSourceDefinition.java
b/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/OpenGaussXADataSourceDefinition.java
deleted file mode 100644
index 3c4c2c4da17..00000000000
---
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/OpenGaussXADataSourceDefinition.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect;
-
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
-
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * XA data source definition for openGauss.
- */
-public final class OpenGaussXADataSourceDefinition implements
XADataSourceDefinition {
-
- @Override
- public Collection<String> getXADriverClassNames() {
- return Collections.singletonList("org.opengauss.xa.PGXADataSource");
- }
-
- @Override
- public String getDatabaseType() {
- return "openGauss";
- }
-}
diff --git
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/OracleXADataSourceDefinition.java
b/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/OracleXADataSourceDefinition.java
deleted file mode 100644
index 5967eaea712..00000000000
---
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/OracleXADataSourceDefinition.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect;
-
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
-
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * XA data source definition for Oracle.
- */
-public final class OracleXADataSourceDefinition implements
XADataSourceDefinition {
-
- @Override
- public Collection<String> getXADriverClassNames() {
- return
Collections.singletonList("oracle.jdbc.xa.client.OracleXADataSource");
- }
-
- @Override
- public String getDatabaseType() {
- return "Oracle";
- }
-}
diff --git
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/PostgreSQLXADataSourceDefinition.java
b/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/PostgreSQLXADataSourceDefinition.java
deleted file mode 100644
index 1be167c8dc1..00000000000
---
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/PostgreSQLXADataSourceDefinition.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect;
-
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
-
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * XA data source definition for PostgreSQL.
- */
-public final class PostgreSQLXADataSourceDefinition implements
XADataSourceDefinition {
-
- @Override
- public Collection<String> getXADriverClassNames() {
- return Collections.singletonList("org.postgresql.xa.PGXADataSource");
- }
-
- @Override
- public String getDatabaseType() {
- return "PostgreSQL";
- }
-}
diff --git
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/SQLServerXADataSourceDefinition.java
b/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/SQLServerXADataSourceDefinition.java
deleted file mode 100644
index 3e132853a9c..00000000000
---
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/SQLServerXADataSourceDefinition.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect;
-
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
-
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * XA data source definition for SQLServer.
- */
-public final class SQLServerXADataSourceDefinition implements
XADataSourceDefinition {
-
- @Override
- public Collection<String> getXADriverClassNames() {
- return
Collections.singletonList("com.microsoft.sqlserver.jdbc.SQLServerXADataSource");
- }
-
- @Override
- public String getDatabaseType() {
- return "SQLServer";
- }
-}
diff --git
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/swapper/DataSourceSwapper.java
b/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/swapper/DataSourceSwapper.java
index 81ae9d42717..d1bf1d7c361 100644
---
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/swapper/DataSourceSwapper.java
+++
b/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/swapper/DataSourceSwapper.java
@@ -20,15 +20,16 @@ package
org.apache.shardingsphere.transaction.xa.jta.datasource.swapper;
import com.google.common.base.CaseFormat;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.infra.datasource.pool.CatalogSwitchableDataSource;
import
org.apache.shardingsphere.infra.datasource.pool.props.creator.DataSourcePoolPropertiesCreator;
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
import
org.apache.shardingsphere.transaction.xa.jta.exception.XADataSourceInitializeException;
import javax.sql.DataSource;
import javax.sql.XADataSource;
import java.lang.reflect.Method;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -42,7 +43,9 @@ public final class DataSourceSwapper {
private static final String SETTER_PREFIX = "set";
- private final XADataSourceDefinition xaDataSourceDefinition;
+ private final DatabaseType databaseType;
+
+ private final Collection<String> xaDriverClassNames;
/**
* Swap data source to database access configuration.
@@ -57,13 +60,13 @@ public final class DataSourceSwapper {
}
private XADataSource createXADataSource() {
- for (String each : xaDataSourceDefinition.getXADriverClassNames()) {
+ for (String each : xaDriverClassNames) {
try {
return loadXADataSource(each);
} catch (final ReflectiveOperationException ignored) {
}
}
- throw new XADataSourceInitializeException(xaDataSourceDefinition);
+ throw new XADataSourceInitializeException(databaseType);
}
private XADataSource loadXADataSource(final String xaDataSourceClassName)
throws ReflectiveOperationException {
diff --git
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/exception/XADataSourceInitializeException.java
b/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/exception/XADataSourceInitializeException.java
index a414bf47e98..60bb039331c 100644
---
a/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/exception/XADataSourceInitializeException.java
+++
b/kernel/transaction/type/xa/core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/exception/XADataSourceInitializeException.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.transaction.xa.jta.exception;
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import
org.apache.shardingsphere.infra.exception.external.sql.sqlstate.XOpenSQLState;
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
/**
* XA data source initialize exception.
@@ -27,7 +27,7 @@ public final class XADataSourceInitializeException extends
XATransactionSQLExcep
private static final long serialVersionUID = -4515239569528215614L;
- public XADataSourceInitializeException(final XADataSourceDefinition
xaDataSourceDefinition) {
- super(XOpenSQLState.INVALID_TRANSACTION_STATE, 0, "Failed to create
'%s' XA data source.", xaDataSourceDefinition.getType());
+ public XADataSourceInitializeException(final DatabaseType databaseType) {
+ super(XOpenSQLState.INVALID_TRANSACTION_STATE, 0, "Failed to create
'%s' XA data source.", databaseType.getType());
}
}
diff --git
a/kernel/transaction/type/xa/core/src/main/resources/META-INF/services/org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition
b/kernel/transaction/type/xa/core/src/main/resources/META-INF/services/org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition
deleted file mode 100644
index 1246fcc76f5..00000000000
---
a/kernel/transaction/type/xa/core/src/main/resources/META-INF/services/org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.MySQLXADataSourceDefinition
-org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.MariaDBXADataSourceDefinition
-org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.PostgreSQLXADataSourceDefinition
-org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.OpenGaussXADataSourceDefinition
-org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.OracleXADataSourceDefinition
-org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.SQLServerXADataSourceDefinition
-org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.H2XADataSourceDefinition
-org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.FirebirdXADataSourceDefinition
diff --git
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/fixture/DataSourceUtils.java
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/fixture/DataSourceUtils.java
index ab85979f268..371e1b88a02 100644
---
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/fixture/DataSourceUtils.java
+++
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/fixture/DataSourceUtils.java
@@ -21,10 +21,10 @@ import com.atomikos.jdbc.AtomikosDataSourceBean;
import com.zaxxer.hikari.HikariDataSource;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
+import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.transaction.DialectTransactionOption;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.database.connector.core.type.DatabaseTypeRegistry;
import
org.apache.shardingsphere.infra.exception.generic.UnsupportedSQLOperationException;
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
import
org.apache.shardingsphere.transaction.xa.jta.datasource.swapper.DataSourceSwapper;
import javax.sql.DataSource;
@@ -69,7 +69,8 @@ public final class DataSourceUtils {
private static AtomikosDataSourceBean createAtomikosDataSourceBean(final
DatabaseType databaseType, final DataSource dataSource, final String
databaseName) {
AtomikosDataSourceBean result = new AtomikosDataSourceBean();
result.setUniqueResourceName(databaseName);
- result.setXaDataSource(new
DataSourceSwapper(DatabaseTypedSPILoader.getService(XADataSourceDefinition.class,
databaseType)).swap(dataSource));
+ DialectTransactionOption transactionOption = new
DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData().getTransactionOption();
+ result.setXaDataSource(new DataSourceSwapper(databaseType,
transactionOption.getXaDriverClassNames()).swap(dataSource));
return result;
}
diff --git
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/FirebirdXAConnectionWrapperTest.java
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/FirebirdXAConnectionWrapperTest.java
index 175e1f15d1d..cdc10605145 100644
---
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/FirebirdXAConnectionWrapperTest.java
+++
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/FirebirdXAConnectionWrapperTest.java
@@ -18,12 +18,13 @@
package org.apache.shardingsphere.transaction.xa.jta.connection.dialect;
import com.zaxxer.hikari.HikariDataSource;
+import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.transaction.DialectTransactionOption;
import
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.database.connector.core.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.transaction.xa.fixture.DataSourceUtils;
import
org.apache.shardingsphere.transaction.xa.jta.connection.XAConnectionWrapper;
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
import
org.apache.shardingsphere.transaction.xa.jta.datasource.swapper.DataSourceSwapper;
import org.firebirdsql.ds.FBXAConnection;
import org.firebirdsql.jdbc.FBConnection;
@@ -53,8 +54,9 @@ class FirebirdXAConnectionWrapperTest {
}
private XADataSource createXADataSource() {
+ DialectTransactionOption transactionOption = new
DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData().getTransactionOption();
DataSource dataSource = DataSourceUtils.build(HikariDataSource.class,
databaseType, "foo_ds");
- return new
DataSourceSwapper(DatabaseTypedSPILoader.getService(XADataSourceDefinition.class,
databaseType)).swap(dataSource);
+ return new DataSourceSwapper(databaseType,
transactionOption.getXaDriverClassNames()).swap(dataSource);
}
private Connection mockConnection() throws SQLException {
diff --git
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/H2XAConnectionWrapperTest.java
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/H2XAConnectionWrapperTest.java
index 84106ae634a..1f8f9c3df8d 100644
---
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/H2XAConnectionWrapperTest.java
+++
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/H2XAConnectionWrapperTest.java
@@ -18,12 +18,13 @@
package org.apache.shardingsphere.transaction.xa.jta.connection.dialect;
import com.zaxxer.hikari.HikariDataSource;
+import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.transaction.DialectTransactionOption;
import
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.database.connector.core.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.transaction.xa.fixture.DataSourceUtils;
import
org.apache.shardingsphere.transaction.xa.jta.connection.XAConnectionWrapper;
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
import
org.apache.shardingsphere.transaction.xa.jta.datasource.swapper.DataSourceSwapper;
import org.h2.jdbc.JdbcConnection;
import org.h2.jdbcx.JdbcXAConnection;
@@ -51,8 +52,9 @@ class H2XAConnectionWrapperTest {
}
private XADataSource createXADataSource() {
+ DialectTransactionOption transactionOption = new
DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData().getTransactionOption();
DataSource dataSource = DataSourceUtils.build(HikariDataSource.class,
databaseType, "foo_ds");
- return new
DataSourceSwapper(DatabaseTypedSPILoader.getService(XADataSourceDefinition.class,
databaseType)).swap(dataSource);
+ return new DataSourceSwapper(databaseType,
transactionOption.getXaDriverClassNames()).swap(dataSource);
}
private Connection mockConnection() throws SQLException {
diff --git
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MariaDBXAConnectionWrapperTest.java
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MariaDBXAConnectionWrapperTest.java
index 7679d8b1831..112de19033b 100644
---
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MariaDBXAConnectionWrapperTest.java
+++
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MariaDBXAConnectionWrapperTest.java
@@ -18,12 +18,13 @@
package org.apache.shardingsphere.transaction.xa.jta.connection.dialect;
import com.zaxxer.hikari.HikariDataSource;
+import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.transaction.DialectTransactionOption;
import
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.database.connector.core.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.transaction.xa.fixture.DataSourceUtils;
import
org.apache.shardingsphere.transaction.xa.jta.connection.XAConnectionWrapper;
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
import
org.apache.shardingsphere.transaction.xa.jta.datasource.swapper.DataSourceSwapper;
import org.junit.jupiter.api.Test;
import org.mariadb.jdbc.MariaDbConnection;
@@ -51,8 +52,9 @@ class MariaDBXAConnectionWrapperTest {
}
private XADataSource createXADataSource() {
+ DialectTransactionOption transactionOption = new
DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData().getTransactionOption();
DataSource dataSource = DataSourceUtils.build(HikariDataSource.class,
databaseType, "foo_ds");
- return new
DataSourceSwapper(DatabaseTypedSPILoader.getService(XADataSourceDefinition.class,
databaseType)).swap(dataSource);
+ return new DataSourceSwapper(databaseType,
transactionOption.getXaDriverClassNames()).swap(dataSource);
}
private Connection mockConnection() throws SQLException {
diff --git
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MySQLXAConnectionWrapperTest.java
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MySQLXAConnectionWrapperTest.java
index 78350a053fd..03d23a4f646 100644
---
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MySQLXAConnectionWrapperTest.java
+++
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MySQLXAConnectionWrapperTest.java
@@ -20,12 +20,13 @@ package
org.apache.shardingsphere.transaction.xa.jta.connection.dialect;
import com.mysql.cj.jdbc.JdbcConnection;
import com.mysql.cj.jdbc.MysqlXAConnection;
import com.zaxxer.hikari.HikariDataSource;
+import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.transaction.DialectTransactionOption;
import
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.database.connector.core.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.transaction.xa.fixture.DataSourceUtils;
import
org.apache.shardingsphere.transaction.xa.jta.connection.XAConnectionWrapper;
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
import
org.apache.shardingsphere.transaction.xa.jta.datasource.swapper.DataSourceSwapper;
import org.junit.jupiter.api.Test;
@@ -52,8 +53,9 @@ class MySQLXAConnectionWrapperTest {
}
private XADataSource createXADataSource() {
+ DialectTransactionOption transactionOption = new
DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData().getTransactionOption();
DataSource dataSource = DataSourceUtils.build(HikariDataSource.class,
databaseType, "foo_ds");
- return new
DataSourceSwapper(DatabaseTypedSPILoader.getService(XADataSourceDefinition.class,
databaseType)).swap(dataSource);
+ return new DataSourceSwapper(databaseType,
transactionOption.getXaDriverClassNames()).swap(dataSource);
}
private Connection mockConnection() throws SQLException {
diff --git
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OpenGaussXAConnectionWrapperTest.java
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OpenGaussXAConnectionWrapperTest.java
index 733c69ba571..58f83bf6817 100644
---
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OpenGaussXAConnectionWrapperTest.java
+++
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OpenGaussXAConnectionWrapperTest.java
@@ -18,12 +18,13 @@
package org.apache.shardingsphere.transaction.xa.jta.connection.dialect;
import com.zaxxer.hikari.HikariDataSource;
+import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.transaction.DialectTransactionOption;
import
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.database.connector.core.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.transaction.xa.fixture.DataSourceUtils;
import
org.apache.shardingsphere.transaction.xa.jta.connection.XAConnectionWrapper;
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
import
org.apache.shardingsphere.transaction.xa.jta.datasource.swapper.DataSourceSwapper;
import org.junit.jupiter.api.Test;
import org.opengauss.core.BaseConnection;
@@ -51,8 +52,9 @@ class OpenGaussXAConnectionWrapperTest {
}
private XADataSource createXADataSource() {
+ DialectTransactionOption transactionOption = new
DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData().getTransactionOption();
DataSource dataSource = DataSourceUtils.build(HikariDataSource.class,
databaseType, "foo_ds");
- return new
DataSourceSwapper(DatabaseTypedSPILoader.getService(XADataSourceDefinition.class,
databaseType)).swap(dataSource);
+ return new DataSourceSwapper(databaseType,
transactionOption.getXaDriverClassNames()).swap(dataSource);
}
private Connection mockConnection() throws SQLException {
diff --git
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OracleXAConnectionWrapperTest.java
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OracleXAConnectionWrapperTest.java
index 29b5107399b..c0f42d2297f 100644
---
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OracleXAConnectionWrapperTest.java
+++
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OracleXAConnectionWrapperTest.java
@@ -19,12 +19,13 @@ package
org.apache.shardingsphere.transaction.xa.jta.connection.dialect;
import com.zaxxer.hikari.HikariDataSource;
import oracle.jdbc.xa.client.OracleXAConnection;
+import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.transaction.DialectTransactionOption;
import
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.database.connector.core.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.transaction.xa.fixture.DataSourceUtils;
import
org.apache.shardingsphere.transaction.xa.jta.connection.XAConnectionWrapper;
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
import
org.apache.shardingsphere.transaction.xa.jta.datasource.swapper.DataSourceSwapper;
import org.junit.jupiter.api.Test;
import org.postgresql.core.BaseConnection;
@@ -51,8 +52,9 @@ class OracleXAConnectionWrapperTest {
}
private XADataSource createXADataSource() {
+ DialectTransactionOption transactionOption = new
DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData().getTransactionOption();
DataSource dataSource = DataSourceUtils.build(HikariDataSource.class,
databaseType, "foo_ds");
- return new
DataSourceSwapper(DatabaseTypedSPILoader.getService(XADataSourceDefinition.class,
databaseType)).swap(dataSource);
+ return new DataSourceSwapper(databaseType,
transactionOption.getXaDriverClassNames()).swap(dataSource);
}
private Connection mockConnection() throws SQLException {
diff --git
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/PostgreSQLXAConnectionWrapperTest.java
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/PostgreSQLXAConnectionWrapperTest.java
index eab091f1170..de0ea1ff2b7 100644
---
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/PostgreSQLXAConnectionWrapperTest.java
+++
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/PostgreSQLXAConnectionWrapperTest.java
@@ -18,12 +18,13 @@
package org.apache.shardingsphere.transaction.xa.jta.connection.dialect;
import com.zaxxer.hikari.HikariDataSource;
+import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.transaction.DialectTransactionOption;
import
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.database.connector.core.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.transaction.xa.fixture.DataSourceUtils;
import
org.apache.shardingsphere.transaction.xa.jta.connection.XAConnectionWrapper;
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
import
org.apache.shardingsphere.transaction.xa.jta.datasource.swapper.DataSourceSwapper;
import org.junit.jupiter.api.Test;
import org.postgresql.core.BaseConnection;
@@ -51,8 +52,9 @@ class PostgreSQLXAConnectionWrapperTest {
}
private XADataSource createXADataSource() {
+ DialectTransactionOption transactionOption = new
DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData().getTransactionOption();
DataSource dataSource = DataSourceUtils.build(HikariDataSource.class,
databaseType, "foo_ds");
- return new
DataSourceSwapper(DatabaseTypedSPILoader.getService(XADataSourceDefinition.class,
databaseType)).swap(dataSource);
+ return new DataSourceSwapper(databaseType,
transactionOption.getXaDriverClassNames()).swap(dataSource);
}
private Connection mockConnection() throws SQLException {
diff --git
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/FirebirdXADataSourceDefinitionTest.java
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/FirebirdXADataSourceDefinitionTest.java
deleted file mode 100644
index af55525c8b6..00000000000
---
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/FirebirdXADataSourceDefinitionTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.Collections;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class FirebirdXADataSourceDefinitionTest {
-
- @Test
- void assertGetXADriverClassName() {
- assertThat(new
FirebirdXADataSourceDefinition().getXADriverClassNames(),
is(Collections.singletonList("org.firebirdsql.ds.FBXADataSource")));
- }
-}
diff --git
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/H2XADataSourceDefinitionTest.java
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/H2XADataSourceDefinitionTest.java
deleted file mode 100644
index c608821c75c..00000000000
---
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/H2XADataSourceDefinitionTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.Collections;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class H2XADataSourceDefinitionTest {
-
- @Test
- void assertGetXADriverClassName() {
- assertThat(new H2XADataSourceDefinition().getXADriverClassNames(),
is(Collections.singletonList("org.h2.jdbcx.JdbcDataSource")));
- }
-}
diff --git
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/MariaDBXADataSourceDefinitionTest.java
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/MariaDBXADataSourceDefinitionTest.java
deleted file mode 100644
index 5a33c5bb5c4..00000000000
---
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/MariaDBXADataSourceDefinitionTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect;
-
-import org.junit.jupiter.api.Test;
-import org.mariadb.jdbc.MariaDbDataSource;
-
-import java.util.Collections;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class MariaDBXADataSourceDefinitionTest {
-
- @Test
- void assertGetXADriverClassName() {
- assertThat(new
MariaDBXADataSourceDefinition().getXADriverClassNames(),
is(Collections.singletonList(MariaDbDataSource.class.getName())));
- }
-}
diff --git
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/MySQLXADataSourceDefinitionTest.java
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/MySQLXADataSourceDefinitionTest.java
deleted file mode 100644
index 9a1151446e8..00000000000
---
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/MySQLXADataSourceDefinitionTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.Arrays;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class MySQLXADataSourceDefinitionTest {
-
- @Test
- void assertGetXADriverClassName() {
- assertThat(new MySQLXADataSourceDefinition().getXADriverClassNames(),
is(Arrays.asList("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource",
"com.mysql.cj.jdbc.MysqlXADataSource")));
- }
-}
diff --git
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/OpenGaussXADataSourceDefinitionTest.java
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/OpenGaussXADataSourceDefinitionTest.java
deleted file mode 100644
index 1728cbfb193..00000000000
---
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/OpenGaussXADataSourceDefinitionTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.Collections;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class OpenGaussXADataSourceDefinitionTest {
-
- @Test
- void assertGetXADriverClassName() {
- assertThat(new
OpenGaussXADataSourceDefinition().getXADriverClassNames(),
is(Collections.singletonList("org.opengauss.xa.PGXADataSource")));
- }
-}
diff --git
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/OracleXADataSourceDefinitionTest.java
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/OracleXADataSourceDefinitionTest.java
deleted file mode 100644
index 142dfcea542..00000000000
---
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/OracleXADataSourceDefinitionTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.Collections;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class OracleXADataSourceDefinitionTest {
-
- @Test
- void assertGetXADriverClassName() {
- assertThat(new OracleXADataSourceDefinition().getXADriverClassNames(),
is(Collections.singletonList("oracle.jdbc.xa.client.OracleXADataSource")));
- }
-}
diff --git
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/PostgreSQLXADataSourceDefinitionTest.java
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/PostgreSQLXADataSourceDefinitionTest.java
deleted file mode 100644
index 65f41b0c818..00000000000
---
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/PostgreSQLXADataSourceDefinitionTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.Collections;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class PostgreSQLXADataSourceDefinitionTest {
-
- @Test
- void assertGetXADriverClassName() {
- assertThat(new
PostgreSQLXADataSourceDefinition().getXADriverClassNames(),
is(Collections.singletonList("org.postgresql.xa.PGXADataSource")));
- }
-}
diff --git
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/SQLServerXADataSourceDefinitionTest.java
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/SQLServerXADataSourceDefinitionTest.java
deleted file mode 100644
index b2ddb406f8e..00000000000
---
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/dialect/SQLServerXADataSourceDefinitionTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.Collections;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class SQLServerXADataSourceDefinitionTest {
-
- @Test
- void assertGetXADriverClassName() {
- assertThat(new
SQLServerXADataSourceDefinition().getXADriverClassNames(),
is(Collections.singletonList("com.microsoft.sqlserver.jdbc.SQLServerXADataSource")));
- }
-}
diff --git
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/swapper/DataSourceSwapperTest.java
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/swapper/DataSourceSwapperTest.java
index 09ca636ade8..be55023a6d6 100644
---
a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/swapper/DataSourceSwapperTest.java
+++
b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/swapper/DataSourceSwapperTest.java
@@ -17,37 +17,28 @@
package org.apache.shardingsphere.transaction.xa.jta.datasource.swapper;
-import com.google.common.collect.ImmutableList;
+import
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.transaction.DialectTransactionOption;
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import
org.apache.shardingsphere.database.connector.core.type.DatabaseTypeRegistry;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.test.infra.fixture.jdbc.MockedDataSource;
-import
org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
import org.h2.jdbcx.JdbcDataSource;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
import javax.sql.XADataSource;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.isA;
-import static org.mockito.Mockito.when;
-@ExtendWith(MockitoExtension.class)
class DataSourceSwapperTest {
- @Mock
- private XADataSourceDefinition xaDataSourceDefinition;
-
- @BeforeEach
- void setUp() {
-
when(xaDataSourceDefinition.getXADriverClassNames()).thenReturn(ImmutableList.of("org.h2.jdbcx.JdbcDataSource"));
- }
+ private final DatabaseType databaseType =
TypedSPILoader.getService(DatabaseType.class, "H2");
@Test
void assertSwap() {
- DataSourceSwapper swapper = new
DataSourceSwapper(xaDataSourceDefinition);
+ DialectTransactionOption transactionOption = new
DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData().getTransactionOption();
+ DataSourceSwapper swapper = new DataSourceSwapper(databaseType,
transactionOption.getXaDriverClassNames());
assertResult(swapper.swap(new MockedDataSource()));
}