You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ra...@apache.org on 2003/08/08 20:33:17 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/otm/transaction WebSphereTransactionFactory.java
raghu 2003/08/08 11:33:17
Modified: src/java/org/apache/ojb/odmg/transaction
WebSphereTransactionManagerFactory.java
src/java/org/apache/ojb/otm/transaction
WebSphereTransactionFactory.java
Log:
PR: #OJB198
Submitted by: Raghuram Rajah
Two changes,
- Added support for WAS 4.x, need to be verified. I don't have WAS 4.x
- Fixed issue with support for WAS 5.x, to use TransactionManagerFactory.getTransactionManager instead of JTSXA.getTransactionManager (no such method exists, a JTSXA.getInstance() could be used, but TransactionManagerFactory.getTransactionManager is a better way)
Revision Changes Path
1.2 +47 -27 db-ojb/src/java/org/apache/ojb/odmg/transaction/WebSphereTransactionManagerFactory.java
Index: WebSphereTransactionManagerFactory.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/transaction/WebSphereTransactionManagerFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WebSphereTransactionManagerFactory.java 1 Feb 2003 18:29:36 -0000 1.1
+++ WebSphereTransactionManagerFactory.java 8 Aug 2003 18:33:17 -0000 1.2
@@ -62,10 +62,14 @@
import org.apache.ojb.broker.util.logging.Logger;
import org.apache.ojb.broker.util.logging.LoggerFactory;
+
+
public class WebSphereTransactionManagerFactory
implements TransactionManagerFactory
{
+
private static Logger log;
+
/**
* Constructor for WebSphereTransactionManagerFactory.
*/
@@ -74,6 +78,7 @@
super();
log = LoggerFactory.getLogger(WebSphereTransactionManagerFactory.class);
}
+
/**
* use reflection to bind to the appropriate websphere classes so we don't have
* to import or have those libraries available.
@@ -87,37 +92,52 @@
if (log.isDebugEnabled())
log.debug(
"WeblogicTransactionManagerFactory.getTransactionManager called");
- TransactionManager retval = null;
+ TransactionManager txManager = null;
try
{
- /**
- * call the method on the class because it is static.
- */
- Class JTSXA = Class.forName("com.ibm.ejcs.jts.jta.JTSXA");
- Method method =
- JTSXA.getMethod("getTransactionManager", null);
- retval = (TransactionManager) method.invoke(JTSXA, null);
- }
- catch (IllegalAccessException iae)
- {
- throw new TransactionManagerFactoryException(
- "IllegalAccessException: " + iae.getMessage());
- }
- catch (ClassNotFoundException cnfe)
- {
- throw new TransactionManagerFactoryException(
- "ClassNotFoundException: " + cnfe.getMessage());
- }
- catch (InvocationTargetException ite)
- {
- throw new TransactionManagerFactoryException(
- "InvocationTargetException: " + ite.getMessage());
+ Class TransactionManagerFactory
+ = Class.forName("com.ibm.ejs.jts.jta.TransactionManagerFactory");
+ Method method = TransactionManagerFactory.getMethod("getTransactionManager", null);
+ txManager = (TransactionManager) method.invoke(TransactionManagerFactory, null);
}
- catch (NoSuchMethodException nsme)
+ catch (Exception e)
{
- throw new TransactionManagerFactoryException(
- "NoSuchMethodException: " + nsme.getMessage());
+ /**
+ * error getting tm for websphere 5, fall back to 4
+ */
+ try
+ {
+ /**
+ * call the method on the class because it is static.
+ * WebSphere 4
+ */
+ Class JTSXA = Class.forName("com.ibm.ejs.jts.jta.JTSXA");
+ Method method =
+ JTSXA.getMethod("getTransactionManager", null);
+ txManager = (TransactionManager) method.invoke(JTSXA, null);
+ }
+ catch (IllegalAccessException illegalAccessException)
+ {
+ throw new TransactionManagerFactoryException(
+ "IllegalAccessException: " + illegalAccessException.getMessage());
+ }
+ catch (ClassNotFoundException classNotFoundException)
+ {
+ throw new TransactionManagerFactoryException(
+ "ClassNotFoundException: " + classNotFoundException.getMessage());
+ }
+ catch (InvocationTargetException invocationTargetException)
+ {
+ throw new TransactionManagerFactoryException(
+ "InvocationTargetException: " + invocationTargetException.getMessage());
+ }
+ catch (NoSuchMethodException noSuchMethodException)
+ {
+ throw new TransactionManagerFactoryException(
+ "NoSuchMethodException: " + noSuchMethodException.getMessage());
+ }
}
- return retval;
+
+ return txManager;
}
}
1.3 +7 -7 db-ojb/src/java/org/apache/ojb/otm/transaction/WebSphereTransactionFactory.java
Index: WebSphereTransactionFactory.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/otm/transaction/WebSphereTransactionFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WebSphereTransactionFactory.java 4 Feb 2003 00:35:11 -0000 1.2
+++ WebSphereTransactionFactory.java 8 Aug 2003 18:33:17 -0000 1.3
@@ -93,17 +93,17 @@
if (log.isDebugEnabled())
log.debug(
"WeblogicTransactionFactory.getTransactionManager called");
- TransactionManager retval = null;
+ TransactionManager txManager = null;
try
{
/**
* call the method on the class because it is static.
* WebSphere 5
*/
- Class JTSXA = Class.forName("com.ibm.ejcs.jts.jta.JTSXA");
- Method method =
- JTSXA.getMethod("getTransactionManager", null);
- retval = (TransactionManager) method.invoke(JTSXA, null);
+ Class TransactionManagerFactory
+ = Class.forName("com.ibm.ejs.jts.jta.TransactionManagerFactory");
+ Method method = TransactionManagerFactory.getMethod("getTransactionManager", null);
+ txManager = (TransactionManager) method.invoke(TransactionManagerFactory, null);
}
catch (Exception e)
{
@@ -119,7 +119,7 @@
Class JTSXA = Class.forName("com.ibm.ejs.jts.jta.JTSXA");
Method method =
JTSXA.getMethod("getTransactionManager", null);
- retval = (TransactionManager) method.invoke(JTSXA, null);
+ txManager = (TransactionManager) method.invoke(JTSXA, null);
}
catch (IllegalAccessException iae)
{
@@ -142,6 +142,6 @@
"NoSuchMethodException: " + nsme.getMessage());
}
}
- return retval;
+ return txManager;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org