[jboss-cvs] JBossAS SVN: r104432 - branches/JBPAPP_5_1/connector/src/main/org/jboss/resource/connectionmanager.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue May 4 10:01:07 EDT 2010


Author: jesper.pedersen
Date: 2010-05-04 10:01:06 -0400 (Tue, 04 May 2010)
New Revision: 104432

Modified:
   branches/JBPAPP_5_1/connector/src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java
Log:
[JBPAPP-3638] XA Resource Recovery (Part 3)

Modified: branches/JBPAPP_5_1/connector/src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java
===================================================================
--- branches/JBPAPP_5_1/connector/src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java	2010-05-04 13:57:54 UTC (rev 104431)
+++ branches/JBPAPP_5_1/connector/src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java	2010-05-04 14:01:06 UTC (rev 104432)
@@ -145,6 +145,7 @@
    private boolean recoveryRegistered = false;
    private XAResourceRecoveryRegistry xrrr = null;
    private SubjectFactory subjectFactory = null;
+   private ManagedConnection recoverMC = null;
    private String recoverSecurityDomain = null;
    private String recoverUserName = null;
    private String recoverPassword = null;
@@ -511,6 +512,8 @@
       {
          if (getXAResourceRecoveryRegistry() != null)
          {
+            close(recoverMC);
+
             getXAResourceRecoveryRegistry().removeXAResourceRecovery(this);
             recoveryRegistered = false;
 
@@ -547,7 +550,7 @@
             // Check if we got a valid Subject instance; requirement for recovery
             if (subject != null)
             {
-               ManagedConnection mc = createManagedConnection(subject, null);
+               ManagedConnection mc = open(subject);
 
                XAResource xaResource = mc.getXAResource();
 
@@ -617,10 +620,12 @@
                log.debug("Error during recovery", re);
          }
       }
+      else
+      {
+         if (log.isDebugEnabled())
+            log.debug("Recovery not registered for " + dmd.getJndiName());
+      }
 
-      if (log.isDebugEnabled())
-         log.debug("Recovery not registered for " + dmd.getJndiName());
-
       return new XAResource[0];
    }
 
@@ -689,6 +694,57 @@
          }
       });
    }
+
+   /**
+    * Open a managed connection
+    * @param s The subject
+    * @return The managed connection
+    * @exception ResourceException Thrown in case of an error
+    */
+   private ManagedConnection open(Subject s) throws ResourceException
+   {
+      if (recoverMC == null)
+      {
+         recoverMC = createManagedConnection(s, null);
+      }
+
+      return recoverMC;
+   }
+
+   /**
+    * Close a managed connection
+    * @param mc The managed connection
+    */
+   private void close(ManagedConnection mc)
+   {
+      if (mc != null)
+      {
+         try
+         {
+            mc.cleanup();
+         }
+         catch (ResourceException ire)
+         {
+            if (log.isDebugEnabled())
+               log.debug("Error during recovery cleanup", ire);
+         }
+      }
+
+      if (mc != null)
+      {
+         try
+         {
+            mc.destroy();
+         }
+         catch (ResourceException ire)
+         {
+            if (log.isDebugEnabled())
+               log.debug("Error during recovery destroy", ire);
+         }
+      }
+
+      mc = null;
+   }
    
    public void setManagedConnectionFactoryAttribute(String name, Class clazz, Object value)
    {




More information about the jboss-cvs-commits mailing list