HHH-5423 Provide a JBoss TS TransactionManagerLookup implementation for standalone (non JNDI) usage

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@20075 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Emmanuel Bernard 2010-07-29 17:31:28 +00:00
parent 7689d5e33c
commit 4d9e5c12c7
2 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,66 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*
*/
package org.hibernate.transaction;
import java.lang.reflect.Method;
import java.util.Properties;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import org.hibernate.HibernateException;
/**
* Return a standalone JTA transaction manager for JBoss Transactions
* Known to work for org.jboss.jbossts:jbossjta:4.11.0.Final
*
* @author Emmanuel Bernard
*/
public class JBossTSStandaloneTransactionManagerLookup implements TransactionManagerLookup {
public TransactionManager getTransactionManager(Properties props) throws HibernateException {
try {
//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 ) {
throw new HibernateException( "Could not obtain JBoss Transactions transaction manager instance", e );
}
}
public String getUserTransactionName() {
return null;
}
public Object getTransactionIdentifier(Transaction transaction) {
return transaction;
}
}

View File

@ -1570,6 +1570,13 @@ hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect</programlisting>
<entry align="center">Borland ES</entry>
</row>
<row>
<entry><literal>org.hibernate.transaction.JBossTSStandaloneTransactionManagerLookup</literal></entry>
<entry align="center">JBoss TS used standalone (ie. outside JBoss AS and a JNDI environment generally).
Known to work for <literal>org.jboss.jbossts:jbossjta:4.11.0.Final</literal></entry>
</row>
</tbody>
</tgroup>
</table>