HHH-7563 - Fallback for JBossAppServerJtaPlatform.locateUserTransaction() to look at "java:jboss" if "java:comp" not available

(cherry picked from commit d743b9b0ba7950d2ab6fa635dd384e06b9811c74)
This commit is contained in:
Steve Ebersole 2012-08-31 11:21:16 -05:00
parent 6713d24d6b
commit 30162bf5ee
2 changed files with 46 additions and 9 deletions

View File

@ -67,8 +67,24 @@ public abstract class AbstractJtaPlatform
protected abstract UserTransaction locateUserTransaction();
public void configure(Map configValues) {
cacheTransactionManager = ConfigurationHelper.getBoolean( AvailableSettings.JTA_CACHE_TM, configValues, true );
cacheUserTransaction = ConfigurationHelper.getBoolean( AvailableSettings.JTA_CACHE_UT, configValues, false );
cacheTransactionManager = ConfigurationHelper.getBoolean(
AvailableSettings.JTA_CACHE_TM,
configValues,
canCacheTransactionManagerByDefault()
);
cacheUserTransaction = ConfigurationHelper.getBoolean(
AvailableSettings.JTA_CACHE_UT,
configValues,
canCacheUserTransactionByDefault()
);
}
protected boolean canCacheTransactionManagerByDefault() {
return true;
}
protected boolean canCacheUserTransactionByDefault() {
return false;
}
protected boolean canCacheTransactionManager() {

View File

@ -36,25 +36,46 @@ import org.hibernate.service.jndi.JndiException;
public class JBossAppServerJtaPlatform extends AbstractJtaPlatform {
public static final String AS7_TM_NAME = "java:jboss/TransactionManager";
public static final String AS4_TM_NAME = "java:/TransactionManager";
public static final String UT_NAME = "java:comp/UserTransaction"; // should work with AS7 and earlier
public static final String JBOSS__UT_NAME = "java:jboss/UserTransaction";
public static final String UT_NAME = "java:comp/UserTransaction";
@Override
protected boolean canCacheUserTransactionByDefault() {
return true;
}
@Override
protected boolean canCacheTransactionManagerByDefault() {
return true;
}
@Override
protected TransactionManager locateTransactionManager() {
try {
return (TransactionManager) jndiService().locate(AS7_TM_NAME);
return (TransactionManager) jndiService().locate( AS7_TM_NAME );
}
catch(JndiException jndiException) {
catch (JndiException jndiException) {
try {
return (TransactionManager) jndiService().locate(AS4_TM_NAME);
return (TransactionManager) jndiService().locate( AS4_TM_NAME );
}
catch(JndiException jndiExceptionInner) {
throw new JndiException("unable to find transaction manager", jndiException);
catch (JndiException jndiExceptionInner) {
throw new JndiException( "unable to find transaction manager", jndiException );
}
}
}
@Override
protected UserTransaction locateUserTransaction() {
return (UserTransaction) jndiService().locate( UT_NAME );
try {
return (UserTransaction) jndiService().locate( JBOSS__UT_NAME );
}
catch (JndiException jndiException) {
try {
return (UserTransaction) jndiService().locate( UT_NAME );
}
catch (JndiException jndiExceptionInner) {
throw new JndiException( "unable to find UserTransaction", jndiException );
}
}
}
}