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:
parent
6713d24d6b
commit
30162bf5ee
|
@ -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() {
|
||||
|
|
|
@ -36,7 +36,18 @@ 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() {
|
||||
|
@ -55,6 +66,16 @@ public class JBossAppServerJtaPlatform extends AbstractJtaPlatform {
|
|||
|
||||
@Override
|
||||
protected UserTransaction locateUserTransaction() {
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue