1 16 package com.ibatis.sqlmap.engine.transaction.external; 17 18 import com.ibatis.sqlmap.engine.transaction.BaseTransactionConfig; 19 import com.ibatis.sqlmap.engine.transaction.Transaction; 20 import com.ibatis.sqlmap.engine.transaction.TransactionException; 21 22 import javax.sql.DataSource ; 23 import java.sql.SQLException ; 24 import java.util.Properties ; 25 26 public class ExternalTransactionConfig extends BaseTransactionConfig { 27 28 private DataSource dataSource; 29 private boolean defaultAutoCommit = false; 30 private boolean setAutoCommitAllowed = true; 31 32 public DataSource getDataSource() { 33 return dataSource; 34 } 35 36 public void setDataSource(DataSource ds) { 37 this.dataSource = ds; 38 } 39 40 public void initialize(Properties props) throws SQLException , TransactionException { 41 String dacProp = props.getProperty("DefaultAutoCommit"); 42 String sacaProp = props.getProperty("SetAutoCommitAllowed"); 43 defaultAutoCommit = "true".equals(dacProp); 44 setAutoCommitAllowed = "true".equals(sacaProp) || sacaProp == null; 45 } 46 47 public Transaction newTransaction(int transactionIsolation) throws SQLException , TransactionException { 48 return new ExternalTransaction(dataSource, defaultAutoCommit, setAutoCommitAllowed, transactionIsolation); 49 } 50 51 } 52 | Popular Tags |