Author: epbernard
Date: 2010-07-30 06:13:00 -0400 (Fri, 30 Jul 2010)
New Revision: 20091
Modified:
search/trunk/hibernate-search-integrationtest/src/test/java/org/hibernate/search/test/integration/jbossjta/infra/JBossTSStandaloneTransactionManagerLookup.java
Log:
HSEARCH-562 Add JTA test with JBoss TS: improve TM lookup
Use non internal methods for the transaction manager lookup method
Modified:
search/trunk/hibernate-search-integrationtest/src/test/java/org/hibernate/search/test/integration/jbossjta/infra/JBossTSStandaloneTransactionManagerLookup.java
===================================================================
---
search/trunk/hibernate-search-integrationtest/src/test/java/org/hibernate/search/test/integration/jbossjta/infra/JBossTSStandaloneTransactionManagerLookup.java 2010-07-30
10:12:26 UTC (rev 20090)
+++
search/trunk/hibernate-search-integrationtest/src/test/java/org/hibernate/search/test/integration/jbossjta/infra/JBossTSStandaloneTransactionManagerLookup.java 2010-07-30
10:13:00 UTC (rev 20091)
@@ -1,5 +1,6 @@
package org.hibernate.search.test.integration.jbossjta.infra;
+import java.lang.reflect.Method;
import java.util.Properties;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
@@ -9,19 +10,24 @@
/**
* Return a standalone JTA transaction manager for JBoss Transactions
- *
+ *
* @author Emmanuel Bernard
*/
public class JBossTSStandaloneTransactionManagerLookup implements
TransactionManagerLookup {
public TransactionManager getTransactionManager(Properties props) throws
HibernateException {
try {
- @SuppressWarnings( "unchecked" )
- Class<? extends TransactionManager> clazz = (Class<? extends
TransactionManager>)
- Class.forName("com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple");
- return clazz.newInstance();
+ //Call jtaPropertyManager.getJTAEnvironmentBean().getTransactionManager();
+
+ //improper camel case name for the class
+ Class<?> propertyManager = Class.forName(
"com.arjuna.ats.jta.common.jtaPropertyManager" );
+ final Method getJTAEnvironmentBean = propertyManager.getMethod(
"getJTAEnvironmentBean" );
+ //static method
+ final Object jtaEnvironmentBean = getJTAEnvironmentBean.invoke( null );
+ final Method getTransactionManager = jtaEnvironmentBean.getClass().getMethod(
"getTransactionManager" );
+ return ( TransactionManager ) getTransactionManager.invoke( jtaEnvironmentBean );
}
- catch (Exception e) {
+ catch ( Exception e ) {
throw new HibernateException( "Could not obtain JBoss Transactions transaction
manager instance", e );
}
}
Show replies by date