User: sparre
Date: 01/09/26 20:48:49
Modified: src/main/org/jboss/tm/usertx/client Tag: Branch_2_4
ClientUserTransaction.java
ClientUserTransactionObjectFactory.java
Added: src/main/org/jboss/tm/usertx/client Tag: Branch_2_4
ServerVMClientUserTransaction.java
Log:
Backported fix for bug #463790 to the 2.4 series
Revision Changes Path
No revision
No revision
1.1.4.1 +4 -38
jboss/src/main/org/jboss/tm/usertx/client/ClientUserTransaction.java
Index: ClientUserTransaction.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/tm/usertx/client/ClientUserTransaction.java,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -r1.1 -r1.1.4.1
--- ClientUserTransaction.java 2001/04/29 08:12:52 1.1
+++ ClientUserTransaction.java 2001/09/27 03:48:49 1.1.4.1
@@ -46,7 +46,7 @@
* propagation contexts of the transactions started here.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ole Husgaard</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.1.4.1 $
*/
public class ClientUserTransaction
implements UserTransaction,
@@ -79,19 +79,9 @@
*/
private ClientUserTransaction()
{
- // See if we have a local TM
- try {
- new InitialContext().lookup("java:/TransactionManager");
-
- // This instance lives in the server.
- isInServer = true;
- } catch (NamingException ex) {
- // This instance lives in a stand-alone client.
- isInServer = false;
-
- // No local TM: Set TPC Factory on GenericProxy.
- GenericProxy.setTPCFactory(this);
- }
+ // Tell the proxy that this is the factory for
+ // transaction propagation contexts.
+ GenericProxy.setTPCFactory(this);
}
// Public --------------------------------------------------------
@@ -103,9 +93,6 @@
public void begin()
throws NotSupportedException, SystemException
{
- if (isInServer)
- throw new SystemException("Cannot use this in the server.");
-
ThreadInfo info = getThreadInfo();
try {
@@ -130,9 +117,6 @@
IllegalStateException,
SystemException
{
- if (isInServer)
- throw new SystemException("Cannot use this in the server.");
-
ThreadInfo info = getThreadInfo();
try {
@@ -165,9 +149,6 @@
IllegalStateException,
SystemException
{
- if (isInServer)
- throw new SystemException("Cannot use this in the server.");
-
ThreadInfo info = getThreadInfo();
try {
@@ -192,9 +173,6 @@
throws IllegalStateException,
SystemException
{
- if (isInServer)
- throw new SystemException("Cannot use this in the server.");
-
ThreadInfo info = getThreadInfo();
try {
@@ -215,9 +193,6 @@
public int getStatus()
throws SystemException
{
- if (isInServer)
- throw new SystemException("Cannot use this in the server.");
-
ThreadInfo info = getThreadInfo();
Object tpc = info.getTpc();
@@ -240,9 +215,6 @@
public void setTransactionTimeout(int seconds)
throws SystemException
{
- if (isInServer)
- throw new SystemException("Cannot use this in the server.");
-
getThreadInfo().setTimeout(seconds);
}
@@ -279,12 +251,6 @@
// Private -------------------------------------------------------
-
- /**
- * Flag that this instance is living in the server.
- * Instances living in the server VM cannot be used.
- */
- private boolean isInServer;
/**
* The RMI remote interface to the real tx service
1.2.4.1 +35 -5
jboss/src/main/org/jboss/tm/usertx/client/ClientUserTransactionObjectFactory.java
Index: ClientUserTransactionObjectFactory.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/tm/usertx/client/ClientUserTransactionObjectFactory.java,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -u -r1.2 -r1.2.4.1
--- ClientUserTransactionObjectFactory.java 2001/04/30 06:32:23 1.2
+++ ClientUserTransactionObjectFactory.java 2001/09/27 03:48:49 1.2.4.1
@@ -10,10 +10,13 @@
import java.util.Hashtable;
import javax.naming.Context;
+import javax.naming.InitialContext;
import javax.naming.Reference;
import javax.naming.Name;
+import javax.naming.NamingException;
import javax.naming.spi.ObjectFactory;
+import javax.transaction.UserTransaction;
/**
* This is an object factory for producing client
@@ -21,21 +24,48 @@
* usage for standalone clients.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ole Husgaard</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.2.4.1 $
*/
public class ClientUserTransactionObjectFactory
implements ObjectFactory
{
+ /**
+ * The <code>UserTransaction</code> this factory will return.
+ * This is evaluated lazily in {@link #getUserTransaction()}.
+ */
+ static private UserTransaction userTransaction = null;
+
+ /**
+ * Get the <code>UserTransaction</code> this factory will return.
+ * This may return a cached value from a previous call.
+ */
+ static private UserTransaction getUserTransaction()
+ {
+ if (userTransaction == null) {
+ // See if we have a local TM
+ try {
+ new InitialContext().lookup("java:/TransactionManager");
+
+ // We execute in the server.
+ userTransaction = ServerVMClientUserTransaction.getSingleton();
+ } catch (NamingException ex) {
+ // We execute in a stand-alone client.
+ userTransaction = ClientUserTransaction.getSingleton();
+ }
+ }
+ return userTransaction;
+ }
+
public Object getObjectInstance(Object obj, Name name,
Context nameCtx, Hashtable environment)
throws Exception
{
Reference ref = (Reference)obj;
- if (ref.getClassName().equals(ClientUserTransaction.class.getName())) {
- return ClientUserTransaction.getSingleton();
- }
- return null;
+ if (!ref.getClassName().equals(ClientUserTransaction.class.getName()))
+ return null;
+
+ return getUserTransaction();
}
}
No revision
No revision
1.1.2.1 +1 -1
jboss/src/main/org/jboss/tm/usertx/client/ServerVMClientUserTransaction.java
Index: ServerVMClientUserTransaction.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/tm/usertx/client/ServerVMClientUserTransaction.java,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- ServerVMClientUserTransaction.java 2001/09/26 20:50:21 1.1
+++ ServerVMClientUserTransaction.java 2001/09/27 03:48:49 1.1.2.1
@@ -1,5 +1,5 @@
/*
- * JBoss, the OpenSource J2EE webOS
+ * JBoss, the OpenSource EJB server
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
@@ -28,7 +28,7 @@
* <code>TransactionManager</code> of the server.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ole Husgaard</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.1.2.1 $
*/
public class ServerVMClientUserTransaction
implements UserTransaction
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development