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

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Jul 2 06:00:38 EDT 2008


Author: jhalliday
Date: 2008-07-02 06:00:37 -0400 (Wed, 02 Jul 2008)
New Revision: 20875

Added:
   labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jta/XAResourceRecoveryHelperWrapper.java
Modified:
   labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jta/TransactionManagerService.java
   labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerService.java
Log:
Added support for the new crash recovery SPI to the app server integration code.  JBTM-335


Added: labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jta/XAResourceRecoveryHelperWrapper.java
===================================================================
--- labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jta/XAResourceRecoveryHelperWrapper.java	                        (rev 0)
+++ labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jta/XAResourceRecoveryHelperWrapper.java	2008-07-02 10:00:37 UTC (rev 20875)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * 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 JBoss Inc.
+ */
+package com.arjuna.ats.internal.jbossatx.jta;
+
+import com.arjuna.ats.jta.recovery.XAResourceRecoveryHelper;
+import org.jboss.tm.XAResourceRecovery;
+
+import javax.transaction.xa.XAResource;
+
+/**
+ * Simple adaptor class that converts the JBossAS transaction integration SPI
+ * version of the recovery interface (org.jboss.tm.XAResourceRecovery) into
+ * the ArjunaJTA version (com.arjuna.ats.jta.recovery.XAResourceRecoveryHelper)
+ * so it can then be registered with the Recovery system (XARecoveryModule)
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com)
+ */
+public class XAResourceRecoveryHelperWrapper implements XAResourceRecoveryHelper
+{
+    private XAResourceRecovery xaResourceRecovery;
+
+    public XAResourceRecoveryHelperWrapper(XAResourceRecovery xaResourceRecovery) {
+        this.xaResourceRecovery = xaResourceRecovery;
+    }
+
+    public boolean initialise(String p) throws Exception
+    {
+        return true;
+    }
+
+    public XAResource[] getXAResources() throws Exception
+    {
+        return xaResourceRecovery.getXAResources();
+    }
+
+    public boolean equals(Object o)
+    {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        XAResourceRecoveryHelperWrapper that = (XAResourceRecoveryHelperWrapper) o;
+
+        if (!xaResourceRecovery.equals(that.xaResourceRecovery)) return false;
+
+        return true;
+    }
+
+    public int hashCode()
+    {
+        return xaResourceRecovery.hashCode();
+    }
+}

Modified: labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jta/TransactionManagerService.java
===================================================================
--- labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jta/TransactionManagerService.java	2008-07-02 09:55:09 UTC (rev 20874)
+++ labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jta/TransactionManagerService.java	2008-07-02 10:00:37 UTC (rev 20875)
@@ -36,9 +36,11 @@
 import org.jboss.logging.Logger;
 
 import com.arjuna.ats.internal.jbossatx.jta.jca.XATerminator;
+import com.arjuna.ats.internal.jbossatx.jta.XAResourceRecoveryHelperWrapper;
 import com.arjuna.ats.internal.jbossatx.agent.LocalJBossAgentImpl;
 import com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple;
 import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple;
+import com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule;
 import com.arjuna.ats.jta.utils.JNDIManager;
 import com.arjuna.ats.jta.common.Environment;
 import com.arjuna.ats.jta.common.jtaPropertyManager;
@@ -46,6 +48,7 @@
 import com.arjuna.ats.arjuna.coordinator.TxControl;
 import com.arjuna.ats.arjuna.coordinator.TxStats;
 import com.arjuna.ats.arjuna.recovery.RecoveryManager;
+import com.arjuna.ats.arjuna.recovery.RecoveryModule;
 
 import com.arjuna.ats.internal.tsmx.mbeans.PropertyServiceJMXPlugin;
 import com.arjuna.common.util.propertyservice.PropertyManagerFactory;
@@ -61,6 +64,7 @@
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
 import java.io.PrintStream;
+import java.util.Vector;
 
 /**
  * JBoss Transaction Manager Service.
@@ -68,7 +72,7 @@
  * @author Richard A. Begg (richard.begg at arjuna.com)
  * @version $Id: TransactionManagerService.java,v 1.5 2005/06/24 15:24:15 kconner Exp $
  */
-public class TransactionManagerService implements TransactionManagerServiceMBean
+public class TransactionManagerService implements TransactionManagerServiceMBean, XAResourceRecoveryRegistry
 {
     /*
     deploy/transaction-beans.xml:
@@ -91,7 +95,7 @@
 
     static {
 		/*
-		 * Override the defualt logging config, force use of the plugin that rewrites log levels to reflect app server level semantics.
+		 * Override the default logging config, force use of the plugin that rewrites log levels to reflect app server level semantics.
 		 * This must be done before the loading of anything that uses the logging, otherwise it's too late to take effect.
 		 * Hence the static initializer block.
 		 * see also http://jira.jboss.com/jira/browse/JBTM-20
@@ -592,6 +596,53 @@
         }
     }
 
+    public void addXAResourceRecovery(XAResourceRecovery xaResourceRecovery)
+    {
+        if(_recoveryManager == null) {
+            log.error("No recovery system in which to register XAResourceRecovery instance");
+            throw new IllegalStateException("No recovery system present in this server");
+        }
+
+        XARecoveryModule xaRecoveryModule = null;
+        for(RecoveryModule recoveryModule : ((Vector<RecoveryModule>)_recoveryManager.getModules())) {
+            if(recoveryModule instanceof XARecoveryModule) {
+                xaRecoveryModule = (XARecoveryModule)recoveryModule;
+                break;
+            }
+        }
+
+        if(xaRecoveryModule == null) {
+            log.error("No suitable recovery module in which to register XAResourceRecovery instance");
+            throw new IllegalStateException("No xa recovery module present in this server");
+        }
+
+        xaRecoveryModule.addXAResourceRecoveryHelper(new XAResourceRecoveryHelperWrapper(xaResourceRecovery));
+    }
+
+    public void removeXAResourceRecovery(XAResourceRecovery xaResourceRecovery)
+    {
+        if(_recoveryManager == null) {
+            log.warn("No recovery system from which to remove XAResourceRecovery instance");
+            return;
+        }
+
+        XARecoveryModule xaRecoveryModule = null;
+        for(RecoveryModule recoveryModule : ((Vector <RecoveryModule>)_recoveryManager.getModules())) {
+            if(recoveryModule instanceof XARecoveryModule) {
+                xaRecoveryModule = (XARecoveryModule)recoveryModule;
+                break;
+            }
+        }
+
+        if(xaRecoveryModule == null) {
+            log.warn("No suitable recovery module in which to register XAResourceRecovery instance");
+            return;
+        }
+
+        xaRecoveryModule.removeXAResourceRecoveryHelper(new XAResourceRecoveryHelperWrapper(xaResourceRecovery));
+    }
+
+
     private void bindRef(String jndiName, String className)
             throws Exception
     {

Modified: labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerService.java
===================================================================
--- labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerService.java	2008-07-02 09:55:09 UTC (rev 20874)
+++ labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/jts/TransactionManagerService.java	2008-07-02 10:00:37 UTC (rev 20875)
@@ -32,15 +32,20 @@
 
 import org.jboss.system.server.ServerConfig;
 import org.jboss.iiop.CorbaORBService;
-import org.jboss.tm.JBossXATerminator;
-import org.jboss.tm.LastResource;
-import org.jboss.tm.XAExceptionFormatter;
+import org.jboss.tm.*;
 import org.jboss.logging.Logger;
 import com.arjuna.ats.internal.jbossatx.jts.PropagationContextWrapper;
 import com.arjuna.ats.internal.jbossatx.jts.jca.XATerminator;
 import com.arjuna.ats.internal.jbossatx.agent.LocalJBossAgentImpl;
 import com.arjuna.ats.internal.jta.transaction.jts.UserTransactionImple;
 import com.arjuna.ats.internal.jta.transaction.jts.TransactionSynchronizationRegistryImple;
+
+// yes we do want the arjunacore version of XARecoveryModule. It's the base class for the
+// JTS version and misconfiuration is common, so it's better to use core, thus allowing for either.
+import com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule;
+// the resource wrapper code is common to JTA and JTS.  Import it from JTA rather than duplicating.
+import com.arjuna.ats.internal.jbossatx.jta.XAResourceRecoveryHelperWrapper;
+
 import com.arjuna.ats.jta.utils.JNDIManager;
 import com.arjuna.ats.jta.common.Environment;
 import com.arjuna.ats.jta.common.jtaPropertyManager;
@@ -48,6 +53,7 @@
 import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
 import com.arjuna.ats.arjuna.coordinator.TxStats;
 import com.arjuna.ats.arjuna.recovery.RecoveryManager;
+import com.arjuna.ats.arjuna.recovery.RecoveryModule;
 import com.arjuna.orbportability.ORB;
 import com.arjuna.orbportability.OA;
 
@@ -68,6 +74,7 @@
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
 import java.io.PrintStream;
+import java.util.Vector;
 
 /**
  * JBoss Transaction Manager Service.
@@ -75,7 +82,7 @@
  * @author Richard A. Begg (richard.begg at arjuna.com)
  * @version $Id: TransactionManagerService.java,v 1.17 2005/06/24 15:24:14 kconner Exp $
  */
-public class TransactionManagerService implements TransactionManagerServiceMBean
+public class TransactionManagerService implements TransactionManagerServiceMBean, XAResourceRecoveryRegistry
 {
     /*
     deploy/transaction-beans.xml:
@@ -103,7 +110,7 @@
 
     static {
 		/*
-		 * Override the defualt logging config, force use of the plugin that rewrites log levels to reflect app server level semantics.
+		 * Override the default logging config, force use of the plugin that rewrites log levels to reflect app server level semantics.
 		 * This must be done before the loading of anything that uses the logging, otherwise it's too late to take effect.
 		 * Hence the static initializer block.
 		 * see also http://jira.jboss.com/jira/browse/JBTM-20
@@ -528,7 +535,7 @@
     public long getResourceRollbackCount() {
         return TxStats.numberOfResourceRollbacks();
     }
-    
+
     /**
      * Set whether the recovery manager should be ran in the same VM as
      * JBoss.  If this is false the Recovery Manager is already expected to
@@ -631,6 +638,52 @@
         }
     }
 
+
+    public void addXAResourceRecovery(XAResourceRecovery xaResourceRecovery)
+    {
+        if(_recoveryManager == null) {
+            log.error("No recovery system in which to register XAResourceRecovery instance");
+            throw new IllegalStateException("No recovery system present in this server");
+        }
+
+        XARecoveryModule xaRecoveryModule = null;
+        for(RecoveryModule recoveryModule : ((Vector<RecoveryModule>)_recoveryManager.getModules())) {
+            if(recoveryModule instanceof XARecoveryModule) {
+                xaRecoveryModule = (XARecoveryModule)recoveryModule;
+                break;
+            }
+        }
+
+        if(xaRecoveryModule == null) {
+            log.error("No suitable recovery module in which to register XAResourceRecovery instance");
+            throw new IllegalStateException("No xa recovery module present in this server");
+        }
+
+        xaRecoveryModule.addXAResourceRecoveryHelper(new XAResourceRecoveryHelperWrapper(xaResourceRecovery));
+    }
+
+    public void removeXAResourceRecovery(XAResourceRecovery xaResourceRecovery)
+    {
+        if(_recoveryManager == null) {
+            log.warn("No recovery system from which to remove XAResourceRecovery instance");
+            return;
+        }
+
+        XARecoveryModule xaRecoveryModule = null;
+        for(RecoveryModule recoveryModule : ((Vector <RecoveryModule>)_recoveryManager.getModules())) {
+            if(recoveryModule instanceof XARecoveryModule) {
+                xaRecoveryModule = (XARecoveryModule)recoveryModule;
+                break;
+            }
+        }
+
+        if(xaRecoveryModule == null) {
+            log.warn("No suitable recovery module in which to register XAResourceRecovery instance");
+            return;
+        }
+
+        xaRecoveryModule.removeXAResourceRecoveryHelper(new XAResourceRecoveryHelperWrapper(xaResourceRecovery));
+    }
     private void bindRef(String jndiName, String className)
             throws Exception
     {




More information about the jboss-svn-commits mailing list