#1042 - JtaTransaction is TenantMode.DB aware

This commit is contained in:
rob bygrave
2017-06-19 22:28:15 +12:00
parent bc74d35651
commit 58c5f01e2b
@@ -28,11 +28,6 @@ public class JtaTransactionManager implements ExternalTransactionManager {
private static final String EBEAN_TXN_RESOURCE = "EBEAN_TXN_RESOURCE";
/**
* The data source.
*/
private DataSource dataSource;
/**
* The Ebean transaction manager.
*/
@@ -59,10 +54,16 @@ public class JtaTransactionManager implements ExternalTransactionManager {
// the public API and hence the Object type and casting here
this.transactionManager = (TransactionManager) txnMgr;
this.dataSource = transactionManager.getDataSource();
this.serverName = transactionManager.getServerName();
}
/**
* Return the current dataSource taking into account multi-tenancy.
*/
private DataSource dataSource() {
return transactionManager.getDataSource();
}
private TransactionSynchronizationRegistry getSyncRegistry() {
try {
InitialContext ctx = new InitialContext();
@@ -121,7 +122,7 @@ public class JtaTransactionManager implements ExternalTransactionManager {
// "wrap" it in a Ebean specific JtaTransaction
String txnId = String.valueOf(System.currentTimeMillis());
JtaTransaction newTrans = new JtaTransaction(txnId, true, ut, dataSource, transactionManager);
JtaTransaction newTrans = new JtaTransaction(txnId, true, ut, dataSource(), transactionManager);
// create and register transaction listener
JtaTxnListener txnListener = createJtaTxnListener(newTrans);