@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2008 the original author or authors .
* Copyright 2002 - 2009 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -19,7 +19,6 @@ package org.springframework.transaction.jta;
@@ -19,7 +19,6 @@ package org.springframework.transaction.jta;
import java.io.Serializable ;
import java.lang.reflect.InvocationTargetException ;
import java.lang.reflect.Method ;
import javax.transaction.InvalidTransactionException ;
import javax.transaction.NotSupportedException ;
import javax.transaction.SystemException ;
@ -31,7 +30,7 @@ import org.springframework.transaction.TransactionDefinition;
@@ -31,7 +30,7 @@ import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionSystemException ;
/ * *
* Special { @link JtaTransactionManager } variant for BEA WebLogic ( 7 . 0 , 8 . 1 and higher ) .
* Special { @link JtaTransactionManager } variant for BEA WebLogic ( 8 . 1 and higher ) .
* Supports the full power of Spring ' s transaction definitions on WebLogic ' s
* transaction coordinator , < i > beyond standard JTA < / i > : transaction names ,
* per - transaction isolation levels , and proper resuming of transactions in all cases .
@ -51,15 +50,11 @@ import org.springframework.transaction.TransactionSystemException;
@@ -51,15 +50,11 @@ import org.springframework.transaction.TransactionSystemException;
* If you ' re not relying on this feature of transaction suspension in the first
* place , Spring ' s standard JtaTransactionManager will behave properly too .
*
* < p > Automatically detects WebLogic Server 7 . 0 or 8 . 1 + and adapts accordingly .
* Usage on a WebLogic client is also supported , although with restricted
* functionality : transaction names cannot be applied there .
*
* < p > By default , the JTA UserTransaction and TransactionManager handles are
* fetched directly from WebLogic ' s < code > TransactionHelper < / code > ( on 8 . 1 + )
* or < code > TxHelper < / code > ( on 7 . 0 ) . This can be overridden by specifying
* "userTransaction" / "userTransactionName" and " transactionManager" / "transactionManagerName" ,
* passing in existing handles or specifying corresponding JNDI locations to look up .
* fetched directly from WebLogic ' s < code > TransactionHelper < / code > . This can be
* overridden by specifying "userTransaction" / "userTransactionName" and
* "transactionManager" / "transactionManagerName" , passing in existing handles
* or specifying corresponding JNDI locations to look up .
*
* @author Juergen Hoeller
* @since 1 . 1
@ -69,7 +64,6 @@ import org.springframework.transaction.TransactionSystemException;
@@ -69,7 +64,6 @@ import org.springframework.transaction.TransactionSystemException;
* @see weblogic . transaction . Transaction # setProperty
* @see weblogic . transaction . TransactionManager # forceResume
* @see weblogic . transaction . TransactionHelper
* @see weblogic . transaction . TxHelper
* /
public class WebLogicJtaTransactionManager extends JtaTransactionManager {
@ -77,14 +71,10 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
@@ -77,14 +71,10 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
private static final String CLIENT_TRANSACTION_MANAGER_CLASS_NAME = "weblogic.transaction.ClientTransactionManager" ;
private static final String TRANSACTION_MANAGER_CLASS_NAME = "weblogic.transaction.TransactionManager" ;
private static final String TRANSACTION_CLASS_NAME = "weblogic.transaction.Transaction" ;
private static final String TRANSACTION_HELPER_CLASS_NAME = "weblogic.transaction.TransactionHelper" ;
private static final String TX_HELPER_CLASS_NAME = "weblogic.transaction.TxHelper" ;
private static final String ISOLATION_LEVEL_KEY = "ISOLATION LEVEL" ;
@ -100,8 +90,6 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
@@ -100,8 +90,6 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
private Method setPropertyMethod ;
private Class transactionHelperClass ;
private Object transactionHelper ;
@ -113,58 +101,48 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
@@ -113,58 +101,48 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
@Override
protected UserTransaction retrieveUserTransaction ( ) throws TransactionSystemException {
loadWebLogicTransactionHelperClass ( ) ;
loadWebLogicTransactionHelper ( ) ;
try {
logger . debug ( "Retrieving JTA UserTransaction from WebLogic TransactionHelper/TxHelper" ) ;
Method getUserTransactionMethod =
this . transactionHelperClass . getMethod ( "getUserTransaction" ) ;
logger . debug ( "Retrieving JTA UserTransaction from WebLogic TransactionHelper" ) ;
Method getUserTransactionMethod = this . transactionHelper . getClass ( ) . getMethod ( "getUserTransaction" ) ;
return ( UserTransaction ) getUserTransactionMethod . invoke ( this . transactionHelper ) ;
}
catch ( InvocationTargetException ex ) {
throw new TransactionSystemException (
"WebLogic's TransactionHelper/TxHelper .getUserTransaction() method failed" , ex . getTargetException ( ) ) ;
"WebLogic's TransactionHelper.getUserTransaction() method failed" , ex . getTargetException ( ) ) ;
}
catch ( Exception ex ) {
throw new TransactionSystemException (
"Could not invoke WebLogic's TransactionHelper/TxHelper .getUserTransaction() method" , ex ) ;
"Could not invoke WebLogic's TransactionHelper.getUserTransaction() method" , ex ) ;
}
}
@Override
protected TransactionManager retrieveTransactionManager ( ) throws TransactionSystemException {
loadWebLogicTransactionHelperClass ( ) ;
loadWebLogicTransactionHelper ( ) ;
try {
logger . debug ( "Retrieving JTA TransactionManager from WebLogic TransactionHelper/TxHelper " ) ;
Method getTransactionManagerMethod = this . transactionHelperClass . getMethod ( "getTransactionManager" ) ;
logger . debug ( "Retrieving JTA TransactionManager from WebLogic TransactionHelper" ) ;
Method getTransactionManagerMethod = this . transactionHelper . get Class( ) . getMethod ( "getTransactionManager" ) ;
return ( TransactionManager ) getTransactionManagerMethod . invoke ( this . transactionHelper ) ;
}
catch ( InvocationTargetException ex ) {
throw new TransactionSystemException (
"WebLogic's TransactionHelper/TxHelper .getTransactionManager() method failed" , ex . getTargetException ( ) ) ;
"WebLogic's TransactionHelper.getTransactionManager() method failed" , ex . getTargetException ( ) ) ;
}
catch ( Exception ex ) {
throw new TransactionSystemException (
"Could not invoke WebLogic's TransactionHelper/TxHelper .getTransactionManager() method" , ex ) ;
"Could not invoke WebLogic's TransactionHelper.getTransactionManager() method" , ex ) ;
}
}
private void loadWebLogicTransactionHelperClass ( ) throws TransactionSystemException {
if ( this . transactionHelperClass = = null ) {
private void loadWebLogicTransactionHelper ( ) throws TransactionSystemException {
if ( this . transactionHelper = = null ) {
try {
try {
this . transactionHelperClass =
getClass ( ) . getClassLoader ( ) . loadClass ( TRANSACTION_HELPER_CLASS_NAME ) ;
Method getTransactionHelperMethod =
this . transactionHelperClass . getMethod ( "getTransactionHelper" , new Class [ 0 ] ) ;
this . transactionHelper = getTransactionHelperMethod . invoke ( null ) ;
logger . debug ( "WebLogic 8.1+ TransactionHelper found" ) ;
}
catch ( ClassNotFoundException ex ) {
this . transactionHelperClass =
getClass ( ) . getClassLoader ( ) . loadClass ( TX_HELPER_CLASS_NAME ) ;
logger . debug ( "WebLogic 7.0 TxHelper found" ) ;
}
Class transactionHelperClass = getClass ( ) . getClassLoader ( ) . loadClass ( TRANSACTION_HELPER_CLASS_NAME ) ;
Method getTransactionHelperMethod = transactionHelperClass . getMethod ( "getTransactionHelper" ) ;
this . transactionHelper = getTransactionHelperMethod . invoke ( null ) ;
logger . debug ( "WebLogic TransactionHelper found" ) ;
}
catch ( InvocationTargetException ex ) {
throw new TransactionSystemException (
@ -180,43 +158,27 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
@@ -180,43 +158,27 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
private void loadWebLogicTransactionClasses ( ) throws TransactionSystemException {
try {
Class userTransactionClass =
getClass ( ) . getClassLoader ( ) . loadClass ( USER_TRANSACTION_CLASS_NAME ) ;
this . weblogicUserTransactionAvailable =
userTransactionClass . isInstance ( getUserTransaction ( ) ) ;
Class userTransactionClass = getClass ( ) . getClassLoader ( ) . loadClass ( USER_TRANSACTION_CLASS_NAME ) ;
this . weblogicUserTransactionAvailable = userTransactionClass . isInstance ( getUserTransaction ( ) ) ;
if ( this . weblogicUserTransactionAvailable ) {
this . beginWithNameMethod =
userTransactionClass . getMethod ( "begin" , new Class [ ] { String . class } ) ;
this . beginWithNameAndTimeoutMethod =
userTransactionClass . getMethod ( "begin" , new Class [ ] { String . class , int . class } ) ;
this . beginWithNameMethod = userTransactionClass . getMethod ( "begin" , String . class ) ;
this . beginWithNameAndTimeoutMethod = userTransactionClass . getMethod ( "begin" , String . class , int . class ) ;
logger . info ( "Support for WebLogic transaction names available" ) ;
}
else {
logger . info ( "Support for WebLogic transaction names not available" ) ;
}
Class transactionManagerClass = null ;
try {
// Try WebLogic 8.1 ClientTransactionManager interface.
transactionManagerClass =
getClass ( ) . getClassLoader ( ) . loadClass ( CLIENT_TRANSACTION_MANAGER_CLASS_NAME ) ;
logger . debug ( "WebLogic 8.1+ ClientTransactionManager found" ) ;
}
catch ( ClassNotFoundException ex ) {
// Fall back to WebLogic TransactionManager interface.
transactionManagerClass =
getClass ( ) . getClassLoader ( ) . loadClass ( TRANSACTION_MANAGER_CLASS_NAME ) ;
logger . debug ( "WebLogic 7.0 TransactionManager found" ) ;
}
// Obtain WebLogic ClientTransactionManager interface.
Class transactionManagerClass =
getClass ( ) . getClassLoader ( ) . loadClass ( CLIENT_TRANSACTION_MANAGER_CLASS_NAME ) ;
logger . debug ( "WebLogic ClientTransactionManager found" ) ;
this . weblogicTransactionManagerAvailable =
transactionManagerClass . isInstance ( getTransactionManager ( ) ) ;
this . weblogicTransactionManagerAvailable = transactionManagerClass . isInstance ( getTransactionManager ( ) ) ;
if ( this . weblogicTransactionManagerAvailable ) {
Class transactionClass = getClass ( ) . getClassLoader ( ) . loadClass ( TRANSACTION_CLASS_NAME ) ;
this . forceResumeMethod =
transactionManagerClass . getMethod ( "forceResume" , new Class [ ] { Transaction . class } ) ;
this . setPropertyMethod =
transactionClass . getMethod ( "setProperty" , new Class [ ] { String . class , Serializable . class } ) ;
this . forceResumeMethod = transactionManagerClass . getMethod ( "forceResume" , Transaction . class ) ;
this . setPropertyMethod = transactionClass . getMethod ( "setProperty" , String . class , Serializable . class ) ;
logger . debug ( "Support for WebLogic forceResume available" ) ;
}
else {
@ -226,7 +188,7 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
@@ -226,7 +188,7 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
catch ( Exception ex ) {
throw new TransactionSystemException (
"Could not initialize WebLogicJtaTransactionManager because WebLogic API classes are not available" ,
ex ) ;
ex ) ;
}
}