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();
|
protected abstract UserTransaction locateUserTransaction();
|
||||||
|
|
||||||
public void configure(Map configValues) {
|
public void configure(Map configValues) {
|
||||||
cacheTransactionManager = ConfigurationHelper.getBoolean( AvailableSettings.JTA_CACHE_TM, configValues, true );
|
cacheTransactionManager = ConfigurationHelper.getBoolean(
|
||||||
cacheUserTransaction = ConfigurationHelper.getBoolean( AvailableSettings.JTA_CACHE_UT, configValues, false );
|
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() {
|
protected boolean canCacheTransactionManager() {
|
||||||
|
|
|
@ -36,25 +36,46 @@ import org.hibernate.service.jndi.JndiException;
|
||||||
public class JBossAppServerJtaPlatform extends AbstractJtaPlatform {
|
public class JBossAppServerJtaPlatform extends AbstractJtaPlatform {
|
||||||
public static final String AS7_TM_NAME = "java:jboss/TransactionManager";
|
public static final String AS7_TM_NAME = "java:jboss/TransactionManager";
|
||||||
public static final String AS4_TM_NAME = "java:/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
|
@Override
|
||||||
protected TransactionManager locateTransactionManager() {
|
protected TransactionManager locateTransactionManager() {
|
||||||
try {
|
try {
|
||||||
return (TransactionManager) jndiService().locate(AS7_TM_NAME);
|
return (TransactionManager) jndiService().locate( AS7_TM_NAME );
|
||||||
}
|
}
|
||||||
catch(JndiException jndiException) {
|
catch (JndiException jndiException) {
|
||||||
try {
|
try {
|
||||||
return (TransactionManager) jndiService().locate(AS4_TM_NAME);
|
return (TransactionManager) jndiService().locate( AS4_TM_NAME );
|
||||||
}
|
}
|
||||||
catch(JndiException jndiExceptionInner) {
|
catch (JndiException jndiExceptionInner) {
|
||||||
throw new JndiException("unable to find transaction manager", jndiException);
|
throw new JndiException( "unable to find transaction manager", jndiException );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected UserTransaction locateUserTransaction() {
|
protected UserTransaction locateUserTransaction() {
|
||||||
|
try {
|
||||||
|
return (UserTransaction) jndiService().locate( JBOSS__UT_NAME );
|
||||||
|
}
|
||||||
|
catch (JndiException jndiException) {
|
||||||
|
try {
|
||||||
return (UserTransaction) jndiService().locate( UT_NAME );
|
return (UserTransaction) jndiService().locate( UT_NAME );
|
||||||
}
|
}
|
||||||
|
catch (JndiException jndiExceptionInner) {
|
||||||
|
throw new JndiException( "unable to find UserTransaction", jndiException );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue