[jboss-cvs] JBossAS SVN: r80532 - in projects/integration/trunk/jboss-transaction-spi/src/main/java/org/jboss/tm: usertx/client and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Nov 4 18:08:05 EST 2008
Author: galder.zamarreno at jboss.com
Date: 2008-11-04 18:08:05 -0500 (Tue, 04 Nov 2008)
New Revision: 80532
Modified:
projects/integration/trunk/jboss-transaction-spi/src/main/java/org/jboss/tm/TransactionManagerLocator.java
projects/integration/trunk/jboss-transaction-spi/src/main/java/org/jboss/tm/usertx/client/ServerVMClientUserTransaction.java
Log:
[JBAS-5908] Overloaded locateTransactionManager() to enable returning null instead of throwing RuntimeException.
Modified: projects/integration/trunk/jboss-transaction-spi/src/main/java/org/jboss/tm/TransactionManagerLocator.java
===================================================================
--- projects/integration/trunk/jboss-transaction-spi/src/main/java/org/jboss/tm/TransactionManagerLocator.java 2008-11-04 22:43:26 UTC (rev 80531)
+++ projects/integration/trunk/jboss-transaction-spi/src/main/java/org/jboss/tm/TransactionManagerLocator.java 2008-11-04 23:08:05 UTC (rev 80532)
@@ -35,6 +35,7 @@
* @todo this really belongs in some integration layer with
* a more pluggable implementation
* @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
* @version $Revision: 37459 $
*/
public class TransactionManagerLocator implements TransactionManagerFactory
@@ -79,6 +80,20 @@
}
/**
+ * Locate the transaction manager
+ *
+ * @param throwExceptionIfUnableToLocate if true and transaction manager
+ * cannot be located, a RuntimeException is thrown, otherwise null is
+ * returned.
+ *
+ * @return the transaction manager
+ */
+ public static TransactionManager locateTransactionManager(boolean throwExceptionIfUnableToLocate)
+ {
+ return getInstance().locate(throwExceptionIfUnableToLocate);
+ }
+
+ /**
* Get the transaction manager
*
* @return the transaction manager
@@ -95,17 +110,31 @@
*/
public TransactionManager locate()
{
+ return locate(true);
+ }
+
+ /**
+ * Locate the transaction manager
+ *
+ * @param throwExceptionIfUnableToLocate if true and transaction manager
+ * cannot be located, a RuntimeException is thrown, otherwise null is
+ * returned.
+ *
+ * @return the transaction manager
+ */
+ public TransactionManager locate(boolean throwExceptionIfUnableToLocate)
+ {
if (tm != null)
return tm;
TransactionManager result = tryJNDI();
if (result == null)
result = usePrivateAPI();
- if (result == null)
+ if (result == null && throwExceptionIfUnableToLocate)
throw new RuntimeException("Unable to locate the transaction manager");
return result;
- }
+ }
/**
* Locate the transaction manager in the well known jndi binding for JBoss
Modified: projects/integration/trunk/jboss-transaction-spi/src/main/java/org/jboss/tm/usertx/client/ServerVMClientUserTransaction.java
===================================================================
--- projects/integration/trunk/jboss-transaction-spi/src/main/java/org/jboss/tm/usertx/client/ServerVMClientUserTransaction.java 2008-11-04 22:43:26 UTC (rev 80531)
+++ projects/integration/trunk/jboss-transaction-spi/src/main/java/org/jboss/tm/usertx/client/ServerVMClientUserTransaction.java 2008-11-04 23:08:05 UTC (rev 80532)
@@ -90,21 +90,9 @@
*/
private ServerVMClientUserTransaction()
{
- this(locateTransactionManager());
+ this(TransactionManagerLocator.locateTransactionManager(false));
}
- private static TransactionManager locateTransactionManager()
- {
- try
- {
- return TransactionManagerLocator.locateTransactionManager();
- }
- catch(RuntimeException re)
- {
- return null;
- }
- }
-
//public constructor for TESTING ONLY
public ServerVMClientUserTransaction(final TransactionManager tm)
{
More information about the jboss-cvs-commits
mailing list