style: format
This commit is contained in:
parent
bff1793697
commit
4b04ea2585
@ -15,8 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.baomidou.dynamic.datasource.annotation;
|
package com.baomidou.dynamic.datasource.annotation;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.dynamic.datasource.tx.DsPropagation;
|
import com.baomidou.dynamic.datasource.tx.DsPropagation;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
@ -35,4 +33,4 @@ public @interface DSTransactional {
|
|||||||
Class<? extends Throwable>[] noRollbackFor() default {};
|
Class<? extends Throwable>[] noRollbackFor() default {};
|
||||||
|
|
||||||
DsPropagation propagation() default DsPropagation.REQUIRED;
|
DsPropagation propagation() default DsPropagation.REQUIRED;
|
||||||
}
|
}
|
@ -26,7 +26,7 @@ import lombok.Getter;
|
|||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
public enum XADataSourceEnum {
|
public enum XADataSourceEnum {
|
||||||
ORACLE(DbType.ORACLE,"oracle.jdbc.xa.client.OracleXADataSource"),
|
ORACLE(DbType.ORACLE, "oracle.jdbc.xa.client.OracleXADataSource"),
|
||||||
MYSQL(DbType.MYSQL, "com.mysql.cj.jdbc.MysqlXADataSource"),
|
MYSQL(DbType.MYSQL, "com.mysql.cj.jdbc.MysqlXADataSource"),
|
||||||
POSTGRE_SQL(DbType.POSTGRE_SQL, "org.postgresql.xa.PGXADataSource"),
|
POSTGRE_SQL(DbType.POSTGRE_SQL, "org.postgresql.xa.PGXADataSource"),
|
||||||
H2(DbType.H2, "org.h2.jdbcx.JdbcDataSource"),
|
H2(DbType.H2, "org.h2.jdbcx.JdbcDataSource"),
|
||||||
@ -40,7 +40,7 @@ public enum XADataSourceEnum {
|
|||||||
this.xaDataSourceClassName = xaDataSourceClassName;
|
this.xaDataSourceClassName = xaDataSourceClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean contains(DbType dbType){
|
public static boolean contains(DbType dbType) {
|
||||||
for (XADataSourceEnum item : values()) {
|
for (XADataSourceEnum item : values()) {
|
||||||
if (item.getDbType() == dbType) {
|
if (item.getDbType() == dbType) {
|
||||||
return true;
|
return true;
|
||||||
@ -49,7 +49,7 @@ public enum XADataSourceEnum {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getByDbType(DbType dbType){
|
public static String getByDbType(DbType dbType) {
|
||||||
for (XADataSourceEnum item : values()) {
|
for (XADataSourceEnum item : values()) {
|
||||||
if (item.getDbType() == dbType) {
|
if (item.getDbType() == dbType) {
|
||||||
return item.getXaDataSourceClassName();
|
return item.getXaDataSourceClassName();
|
||||||
@ -57,4 +57,4 @@ public enum XADataSourceEnum {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -37,8 +37,8 @@ public class AtomikosTransactionFactory extends SpringManagedTransactionFactory
|
|||||||
|
|
||||||
// e.g:ConnectionHolder conHolder = (ConnectionHolder) TransactionSynchronizationManager.getResource(dataSource);
|
// e.g:ConnectionHolder conHolder = (ConnectionHolder) TransactionSynchronizationManager.getResource(dataSource);
|
||||||
if (dataSource instanceof DynamicRoutingDataSource) {
|
if (dataSource instanceof DynamicRoutingDataSource) {
|
||||||
determineDataSource = ((DynamicRoutingDataSource)dataSource).determineDataSource();
|
determineDataSource = ((DynamicRoutingDataSource) dataSource).determineDataSource();
|
||||||
}
|
}
|
||||||
return new SpringManagedTransaction(determineDataSource);
|
return new SpringManagedTransaction(determineDataSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -173,7 +173,7 @@ public class ConnectionFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
savePointMap.put(xid,savePointHolders);
|
savePointMap.put(xid, savePointHolders);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
throw new CannotCreateTransactionException("Could not create JDBC savepoint", ex);
|
throw new CannotCreateTransactionException("Could not create JDBC savepoint", ex);
|
||||||
}
|
}
|
||||||
|
@ -335,8 +335,12 @@ public class ConnectionProxy implements Connection {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {return true;}
|
if (this == o) {
|
||||||
if (!(o instanceof ConnectionProxy)) {return false;}
|
return true;
|
||||||
|
}
|
||||||
|
if (!(o instanceof ConnectionProxy)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
ConnectionProxy that = (ConnectionProxy) o;
|
ConnectionProxy that = (ConnectionProxy) o;
|
||||||
return Objects.equals(connection, that.connection) && Objects.equals(ds, that.ds);
|
return Objects.equals(connection, that.connection) && Objects.equals(ds, that.ds);
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public final class LocalTxUtil {
|
|||||||
try {
|
try {
|
||||||
ConnectionFactory.notify(xid, true);
|
ConnectionFactory.notify(xid, true);
|
||||||
} finally {
|
} finally {
|
||||||
if (!hasSavepoint){
|
if (!hasSavepoint) {
|
||||||
log.debug("dynamic-datasource commit local tx [{}]", TransactionContext.getXID());
|
log.debug("dynamic-datasource commit local tx [{}]", TransactionContext.getXID());
|
||||||
TransactionContext.remove();
|
TransactionContext.remove();
|
||||||
}
|
}
|
||||||
@ -67,10 +67,10 @@ public final class LocalTxUtil {
|
|||||||
try {
|
try {
|
||||||
ConnectionFactory.notify(xid, false);
|
ConnectionFactory.notify(xid, false);
|
||||||
} finally {
|
} finally {
|
||||||
if (!hasSavepoint){
|
if (!hasSavepoint) {
|
||||||
log.debug("dynamic-datasource commit local tx [{}]", TransactionContext.getXID());
|
log.debug("dynamic-datasource commit local tx [{}]", TransactionContext.getXID());
|
||||||
TransactionContext.remove();
|
TransactionContext.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -88,7 +88,7 @@ public class TransactionalTemplate {
|
|||||||
private Object doExecute(TransactionalExecutor transactionalExecutor) throws Throwable {
|
private Object doExecute(TransactionalExecutor transactionalExecutor) throws Throwable {
|
||||||
TransactionalInfo transactionInfo = transactionalExecutor.getTransactionInfo();
|
TransactionalInfo transactionInfo = transactionalExecutor.getTransactionInfo();
|
||||||
DsPropagation propagation = transactionInfo.propagation;
|
DsPropagation propagation = transactionInfo.propagation;
|
||||||
if (!StringUtils.isEmpty(TransactionContext.getXID())&&!propagation.equals(DsPropagation.NESTED)) {
|
if (!StringUtils.isEmpty(TransactionContext.getXID()) && !propagation.equals(DsPropagation.NESTED)) {
|
||||||
return transactionalExecutor.execute();
|
return transactionalExecutor.execute();
|
||||||
}
|
}
|
||||||
boolean state = true;
|
boolean state = true;
|
||||||
@ -169,4 +169,4 @@ public class TransactionalTemplate {
|
|||||||
public boolean existingTransaction() {
|
public boolean existingTransaction() {
|
||||||
return !StringUtils.isEmpty(TransactionContext.getXID());
|
return !StringUtils.isEmpty(TransactionContext.getXID());
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user