本文整理匯總了Java中org.apache.ibatis.transaction.TransactionFactory.setProperties方法的典型用法代碼示例。如果您正苦於以下問題:Java TransactionFactory.setProperties方法的具體用法?Java TransactionFactory.setProperties怎麽用?Java TransactionFactory.setProperties使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.ibatis.transaction.TransactionFactory
的用法示例。
在下文中一共展示了TransactionFactory.setProperties方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: transactionManagerElement
import org.apache.ibatis.transaction.TransactionFactory; //導入方法依賴的package包/類
/**
* 解析<transactionManager>節點,創建對應的TransactionFactory
* <environment>節點定義了連接某個數據庫的信息,
* 其子節點<transactionManager> 的type 會決定我們用什麽類型的事務管理機製。
* @param context
* @return
* @throws Exception
*/
private TransactionFactory transactionManagerElement(XNode context) throws Exception {
if (context != null) {
//type=JDBC,使用jdbc管理事務;type=MANAGED,使用WEB容器(Tomcat、JBOSS)管理事務
String type = context.getStringAttribute("type");
Properties props = context.getChildrenAsProperties();
/*在Configuration初始化的時候,會通過以下語句,給JDBC和MANAGED對應的工廠類
typeAliasRegistry.registerAlias("JDBC", JdbcTransactionFactory.class);
typeAliasRegistry.registerAlias("MANAGED", ManagedTransactionFactory.class);
下述的resolveClass(type).newInstance()會創建對應的工廠實例 */
TransactionFactory factory = (TransactionFactory) resolveClass(type).newInstance();
factory.setProperties(props);
return factory;
}
throw new BuilderException("Environment declaration requires a TransactionFactory.");
}
示例2: transactionManagerElement
import org.apache.ibatis.transaction.TransactionFactory; //導入方法依賴的package包/類
private TransactionFactory transactionManagerElement(XNode context) throws Exception {
if (context != null) {
String type = context.getStringAttribute("type");
Properties props = context.getChildrenAsProperties();
TransactionFactory factory = (TransactionFactory) resolveClass(type).newInstance();
factory.setProperties(props);
return factory;
}
throw new BuilderException("Environment declaration requires a TransactionFactory.");
}
示例3: transactionManagerElement
import org.apache.ibatis.transaction.TransactionFactory; //導入方法依賴的package包/類
private TransactionFactory transactionManagerElement(XNode context) throws Exception {
if (context != null) {
String type = context.getStringAttribute("type");
Properties props = context.getChildrenAsProperties();
TransactionFactory factory = (TransactionFactory) resolveClass(type).newInstance();
factory.setProperties(props);
return factory;
}
throw new BuilderException("Environment declaration requires a TransactionFactory.");
}
示例4: shouldEnsureThatCallsToManagedTransactionAPIDoNotForwardToManagedConnections
import org.apache.ibatis.transaction.TransactionFactory; //導入方法依賴的package包/類
@Test
public void shouldEnsureThatCallsToManagedTransactionAPIDoNotForwardToManagedConnections() throws Exception {
TransactionFactory tf = new ManagedTransactionFactory();
tf.setProperties(new Properties());
Transaction tx = tf.newTransaction(conn);
assertEquals(conn, tx.getConnection());
tx.commit();
tx.rollback();
tx.close();
verify(conn).close();
}
示例5: shouldEnsureThatCallsToManagedTransactionAPIDoNotForwardToManagedConnectionsAndDoesNotCloseConnection
import org.apache.ibatis.transaction.TransactionFactory; //導入方法依賴的package包/類
@Test
public void shouldEnsureThatCallsToManagedTransactionAPIDoNotForwardToManagedConnectionsAndDoesNotCloseConnection() throws Exception {
TransactionFactory tf = new ManagedTransactionFactory();
Properties props = new Properties();
props.setProperty("closeConnection", "false");
tf.setProperties(props);
Transaction tx = tf.newTransaction(conn);
assertEquals(conn, tx.getConnection());
tx.commit();
tx.rollback();
tx.close();
verifyNoMoreInteractions(conn);
}
示例6: transactionManagerElement
import org.apache.ibatis.transaction.TransactionFactory; //導入方法依賴的package包/類
private TransactionFactory transactionManagerElement(XNode context) throws Exception {
if (context != null) {
String type = context.getStringAttribute("type");
Properties props = context.getChildrenAsProperties();
TransactionFactory factory = (TransactionFactory) resolveClass(type).newInstance();
factory.setProperties(props);
return factory;
}
throw new BuilderException("Environment declaration requires a TransactionFactory.");
}
示例7: transactionManagerElement
import org.apache.ibatis.transaction.TransactionFactory; //導入方法依賴的package包/類
private TransactionFactory transactionManagerElement(XNode context) throws Exception {
if (context != null) {
String type = context.getStringAttribute("type");
Properties props = context.getChildrenAsProperties();
//根據type="JDBC"解析返回適當的TransactionFactory
TransactionFactory factory = (TransactionFactory) resolveClass(type).newInstance();
factory.setProperties(props);
return factory;
}
throw new BuilderException("Environment declaration requires a TransactionFactory.");
}