From c3f440cf482062378674008de151ce28dc58836b Mon Sep 17 00:00:00 2001 From: Diego Plentz Date: Tue, 14 Aug 2007 13:49:08 +0000 Subject: [PATCH] [HHH-2778] TransactionManagerLookup implementation for Bitronix Transaction Manager git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@12932 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../BTMTransactionManagerLookup.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 core/src/main/java/org/hibernate/transaction/BTMTransactionManagerLookup.java 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