1 16 17 package org.springframework.transaction.jta; 18 19 import java.lang.reflect.InvocationTargetException ; 20 import java.lang.reflect.Method ; 21 22 import javax.transaction.TransactionManager ; 23 24 import org.apache.commons.logging.Log; 25 import org.apache.commons.logging.LogFactory; 26 27 import org.springframework.beans.factory.FactoryBean; 28 import org.springframework.transaction.TransactionSystemException; 29 30 58 public class WebLogicServerTransactionManagerFactoryBean implements FactoryBean { 59 60 private static final String TX_HELPER_CLASS_NAME = "weblogic.transaction.TxHelper"; 61 62 63 protected final Log logger = LogFactory.getLog(getClass()); 64 65 private final TransactionManager transactionManager; 66 67 68 72 public WebLogicServerTransactionManagerFactoryBean() throws TransactionSystemException { 73 try { 74 Class helperClass = Class.forName(TX_HELPER_CLASS_NAME); 75 logger.debug("Found WebLogic's TxHelper: " + TX_HELPER_CLASS_NAME); 76 Method method = helperClass.getMethod("getTransactionManager", (Class []) null); 77 this.transactionManager = (TransactionManager ) method.invoke(null, (Object []) null); 78 } 79 catch (ClassNotFoundException ex) { 80 throw new TransactionSystemException("Could not find WebLogic's TxHelper class", ex); 81 } 82 catch (InvocationTargetException ex) { 83 throw new TransactionSystemException( 84 "WebLogic's TxHelper.getTransactionManager method failed", ex.getTargetException()); 85 } 86 catch (Exception ex) { 87 throw new TransactionSystemException( 88 "Could not access WebLogic's TxHelper.getTransactionManager method", ex); 89 } 90 } 91 92 93 public Object getObject() { 94 return this.transactionManager; 95 } 96 97 public Class getObjectType() { 98 return this.transactionManager.getClass(); 99 } 100 101 public boolean isSingleton() { 102 return true; 103 } 104 105 } 106 | Popular Tags |