[jboss-svn-commits] JBL Code SVN: r18371 - in labs/jbosstm/trunk: atsintegration/classes/com/arjuna/ats/internal/jbossatx/jts and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Feb 7 08:14:54 EST 2008


Author: jhalliday
Date: 2008-02-07 08:14:54 -0500 (Thu, 07 Feb 2008)
New Revision: 18371

Added:
   labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jts/InboundTransactionCurrentImple.java
   labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/InboundTransactionCurrentInitializer.java
Modified:
   labs/jbosstm/trunk/ArjunaJTS/INSTALL
Log:
Added implementation of the new InboundTransactionCurrent interface from JBossAS transaction integration SPI, to fix problem with inflowed JTS tx context on RMI/IIOP calls not being seen by the app server. JBTM-123 and http://www.jboss.com/index.html?module=bb&op=viewtopic&t=119099


Modified: labs/jbosstm/trunk/ArjunaJTS/INSTALL
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/INSTALL	2008-02-07 12:08:55 UTC (rev 18370)
+++ labs/jbosstm/trunk/ArjunaJTS/INSTALL	2008-02-07 13:14:54 UTC (rev 18371)
@@ -73,6 +73,7 @@
   - add the following lines
          <!-- JBoss TS interceptor -->
          <initializer>com.arjuna.ats.jts.orbspecific.jacorb.interceptors.interposition.InterpositionORBInitializerImpl</initializer>
+         <initializer>com.arjuna.ats.jbossatx.jts.InboundTransactionCurrentInitializer</initializer>
 
 For each deployment of JacORB, you will need to ensure that the jacorb.implname in the jacorb.properties
 file is unique.

Added: labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jts/InboundTransactionCurrentImple.java
===================================================================
--- labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jts/InboundTransactionCurrentImple.java	                        (rev 0)
+++ labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jts/InboundTransactionCurrentImple.java	2008-02-07 13:14:54 UTC (rev 18371)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2008,
+ * @author Redhat Middleware LLC.
+ */
+package com.arjuna.ats.internal.jbossatx.jts;
+
+import org.jboss.iiop.tm.InboundTransactionCurrent;
+import org.jboss.tm.TransactionManagerLocator;
+import org.jboss.logging.Logger;
+import org.omg.CORBA.LocalObject;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+/**
+ * Implementation of the InboundTransactionCurrent interface of the app server's
+ * transaction integration SPI. Provides a way for app server code to obtain the
+ * transaction that was on an inbound CORBA call. The context processing on the
+ * wire is handled by the JTS's RequestInterceptors, here we just provide a way
+ * to expose that context to the app server.
+ *
+ * @see org.jboss.iiop.tm.InboundTransactionCurrent
+ * @see com.arjuna.ats.jbossatx.jts.InboundTransactionCurrentInitializer
+ *
+ * @author jonathan.halliday at redhat.com
+ * @version $Id$
+ */
+public class InboundTransactionCurrentImple extends LocalObject implements InboundTransactionCurrent
+{
+    private Logger log = org.jboss.logging.Logger.getLogger(InboundTransactionCurrentImple.class);
+
+    public Transaction getCurrentTransaction()
+    {
+        if (log.isTraceEnabled())
+        {
+            log.trace("InboundTransactionCurrentImple.getCurrentTransaction() called");
+        }
+
+        TransactionManager transactionManager = null;
+        Transaction transaction = null;
+
+        try
+        {
+            // We need to get a Transaction representation of the tx context that came in on the CORBA call.
+            // The easiest way to do this is to have the JTS transaction manager impl give us the current
+            // transaction. That will cause it to create a Transaction to wrap the context, which saves us
+            // doing it ourselves. Less code duplication is a good thing.
+            transactionManager = TransactionManagerLocator.getInstance().getTransactionManager();
+            transaction = transactionManager.getTransaction();
+            if(transaction != null)
+            {
+                // only problem is, the transaction manager assumes we want the inbound context bound to the Thread.
+                // normally that is user friendly, but in this case the downstream code seems to expect to do the
+                // Thread association itself through a resume() and will be upset if we don't let it. Therefore,
+                // disassociate the tx from the Thread before returning it. Inefficient and a little kludgy.
+                transactionManager.suspend();
+            }
+        } catch(Exception e)
+        {
+            log.error("InboundTransactionCurrentImple.getCurrentTransaction() failed", e);
+            // this is a problem, because we may actually have a valid tx context on the thread
+            // which could cause weird behaviour in downstream code. We need to ensure that code is not called
+            // but the API does not allow for checked excpetion to be thrown, so...
+            throw new RuntimeException("InboundTransactionCurrentImple unable to determine inbound transaction context", e);
+        }
+
+        if (log.isTraceEnabled())
+        {
+            log.trace("InboundTransactionCurrentImple.getCurrentTransaction() returning tx="+transaction);
+        }
+
+        return transaction;
+    }
+}

Added: labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/InboundTransactionCurrentInitializer.java
===================================================================
--- labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/InboundTransactionCurrentInitializer.java	                        (rev 0)
+++ labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/InboundTransactionCurrentInitializer.java	2008-02-07 13:14:54 UTC (rev 18371)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2008,
+ * @author Redhat Middleware LLC.
+ */
+package com.arjuna.ats.jbossatx.jts;
+
+import org.omg.CORBA.LocalObject;
+import org.omg.PortableInterceptor.ORBInitializer;
+import org.omg.PortableInterceptor.ORBInitInfo;
+import org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName;
+import org.jboss.iiop.tm.InboundTransactionCurrent;
+import org.jboss.logging.Logger;
+import com.arjuna.ats.internal.jbossatx.jts.InboundTransactionCurrentImple;
+
+/**
+ * This Initializer is used to register our InboundTransactionCurrent implementation
+ * so that the app server can find it. Used together with the InterpositionORBInitializerImpl
+ * this sets up processing for inbound distributed transaction contexts on the server,
+ * replacing the app server's TxServerInterceptorInitializer.
+ *
+ * @see org.jboss.iiop.tm.InboundTransactionCurrent
+ * @see com.arjuna.ats.internal.jbossatx.jts.InboundTransactionCurrentImple
+ *
+ * @author jonathan.halliday at redhat.com
+ * @version $Id$
+ */
+public class InboundTransactionCurrentInitializer extends LocalObject implements ORBInitializer
+{
+    private Logger log = org.jboss.logging.Logger.getLogger(InboundTransactionCurrentInitializer.class);
+
+    public void pre_init(ORBInitInfo info)
+    {
+        if(log.isTraceEnabled())
+        {
+            log.trace("InboundTransactionCurrentInitializer.pre_init()");
+        }
+
+        try
+        {
+            // Create and register the InboundTransactionCurrent implementation class
+            InboundTransactionCurrentImple inboundTxCurrent = new InboundTransactionCurrentImple();
+            info.register_initial_reference(InboundTransactionCurrent.NAME, inboundTxCurrent);
+        }
+        catch(InvalidName e)
+        {
+            throw new RuntimeException("Could not register initial " +
+                    "reference for InboundTransactionCurrent implementation: " + e);
+        }
+    }
+
+    public void post_init(ORBInitInfo info) {}
+}




More information about the jboss-svn-commits mailing list