1 package org.hibernate.transaction; 3 4 import java.util.Properties ; 5 6 import javax.transaction.TransactionManager ; 7 8 import org.apache.commons.logging.Log; 9 import org.apache.commons.logging.LogFactory; 10 11 import org.hibernate.HibernateException; 12 13 17 public class WebSphereTransactionManagerLookup implements TransactionManagerLookup { 18 19 private static final Log log = LogFactory.getLog(WebSphereTransactionManagerLookup.class); 20 private int version; 21 22 25 public TransactionManager getTransactionManager(Properties props) throws HibernateException { 26 try { 27 Class clazz; 28 try { 29 clazz = Class.forName("com.ibm.ws.Transaction.TransactionManagerFactory"); 30 version = 5; 31 log.info("WebSphere 5.1"); 32 } 33 catch (Exception e) { 34 try { 35 clazz = Class.forName("com.ibm.ejs.jts.jta.TransactionManagerFactory"); 36 version = 5; 37 log.info("WebSphere 5.0"); 38 } 39 catch (Exception e2) { 40 clazz = Class.forName("com.ibm.ejs.jts.jta.JTSXA"); 41 version = 4; 42 log.info("WebSphere 4"); 43 } 44 } 45 46 return (TransactionManager ) clazz.getMethod("getTransactionManager", null).invoke(null, null); 47 } 48 catch (Exception e) { 49 throw new HibernateException( "Could not obtain WebSphere JTSXA instance", e ); 50 } 51 } 52 53 public String getUserTransactionName() { 54 return version==5 ? 55 "java:comp/UserTransaction": 56 "jta/usertransaction"; 57 } 58 59 } | Popular Tags |