diff --git a/core/src/main/java/org/hibernate/transaction/BTMTransactionManagerLookup.java b/core/src/main/java/org/hibernate/transaction/BTMTransactionManagerLookup.java new file mode 100644 index 0000000000..2fc2f3373c --- /dev/null +++ b/core/src/main/java/org/hibernate/transaction/BTMTransactionManagerLookup.java @@ -0,0 +1,34 @@ +package org.hibernate.transaction; + +import java.util.Properties; + +import javax.transaction.TransactionManager; + +import org.hibernate.HibernateException; + +/** + * TransactionManager lookup strategy for BTM + * @author Ludovic Orban + */ +public class BTMTransactionManagerLookup implements TransactionManagerLookup { + + /** + * @see org.hibernate.transaction.TransactionManagerLookup#getTransactionManager(Properties) + */ + public TransactionManager getTransactionManager(Properties props) throws HibernateException { + try { + Class clazz = Class.forName("bitronix.tm.TransactionManagerServices"); + return (TransactionManager) clazz.getMethod("getTransactionManager", null).invoke(null, null); + } + catch (Exception e) { + throw new HibernateException( "Could not obtain BTM transaction manager instance", e ); + } + } + + /** + * @see org.hibernate.transaction.TransactionManagerLookup#getUserTransactionName() + */ + public String getUserTransactionName() { + return "java:comp/UserTransaction"; + } +} \ No newline at end of file