[jboss-cvs] JBossAS SVN: r110503 - branches/JBPAPP_5_1_0_Final_JBPAPP-5820/connector/src/main/org/jboss/resource/connectionmanager.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Feb 1 05:35:58 EST 2011


Author: raggz
Date: 2011-02-01 05:35:58 -0500 (Tue, 01 Feb 2011)
New Revision: 110503

Modified:
   branches/JBPAPP_5_1_0_Final_JBPAPP-5820/connector/src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java
Log:
This is second update to fix JBPAPP-5832. First one was incomplete and did not work, see JBPAPP-5292

Modified: branches/JBPAPP_5_1_0_Final_JBPAPP-5820/connector/src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java
===================================================================
--- branches/JBPAPP_5_1_0_Final_JBPAPP-5820/connector/src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java	2011-01-31 23:31:25 UTC (rev 110502)
+++ branches/JBPAPP_5_1_0_Final_JBPAPP-5820/connector/src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java	2011-02-01 10:35:58 UTC (rev 110503)
@@ -25,6 +25,7 @@
 import java.beans.PropertyEditorManager;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.io.File;
 import java.security.AccessController;
 import java.security.Principal;
 import java.security.PrivilegedAction;
@@ -378,6 +379,7 @@
 
       ResourceAdapter resourceAdapter = null;
       ConnectionDefinitionMetaData cdmd = cmd.getConnectionDefinition(dmd.getConnectionDefinition());
+      rarName = dmd.getRarName();
       
       try
       {
@@ -481,6 +483,12 @@
             if (log.isDebugEnabled())
                log.debug("Registered for XA Resource Recovery: " + xdsdm.getJndiName());
 
+            // Variable substitution
+            recoverUserName = getSubstitutionValue(recoverUserName);
+            recoverPassword = getSubstitutionValue(recoverPassword);
+            recoverSecurityDomain = getSubstitutionValue(recoverSecurityDomain);
+            securityDomain = getSubstitutionValue(securityDomain);
+
             if (log.isDebugEnabled())
             {
                if (recoverUserName != null)
@@ -623,7 +631,8 @@
                }
                catch (Throwable t)
                {
-                  // Ignore
+                  if (log.isDebugEnabled())
+                     log.debug("Unable to verify wrap-xa settings for " + dmd.getJndiName(), t);
                }
 
                if (log.isDebugEnabled())
@@ -639,8 +648,7 @@
          }
          catch (ResourceException re)
          {
-            if (log.isDebugEnabled())
-               log.debug("Error during recovery", re);
+            log.warn("Error during recovery", re);
          }
       }
       else
@@ -731,7 +739,7 @@
                }
                catch (Throwable t)
                {
-                  log.debug("Exception during getSubject()" + t.getMessage(), t);
+                  log.warn("Exception during getSubject()" + t.getMessage(), t);
                }
 
                return null;
@@ -770,8 +778,7 @@
          }
          catch (ResourceException ire)
          {
-            if (log.isDebugEnabled())
-               log.debug("Error during recovery cleanup", ire);
+            log.warn("Error during recovery cleanup", ire);
          }
       }
 
@@ -783,8 +790,7 @@
          }
          catch (ResourceException ire)
          {
-            if (log.isDebugEnabled())
-               log.debug("Error during recovery destroy", ire);
+            log.warn("Error during recovery destroy", ire);
          }
       }
 
@@ -821,8 +827,8 @@
             }
             catch (ResourceException ire)
             {
-               if (log.isDebugEnabled())
-                  log.debug("Error during recovery connection close", ire);
+               log.warn("Error during recovery connection close", ire);
+               return true;
             }
          }
          else
@@ -840,9 +846,7 @@
             }
             catch (Throwable t)
             {
-               if (log.isDebugEnabled())
-                  log.debug("Error during recovery connection close", t);
-
+               log.warn("Error during recovery connection close", t);
                return true;
             }
          }
@@ -1287,4 +1291,113 @@
          description = "RAR Deployment ";
       return description;
    }
+
+   /**
+    * System property substitution
+    * @param input The input string
+    * @return The output
+    */
+   private String getSubstitutionValue(String input)
+   {
+      if (input == null || input.trim().equals(""))
+         return input;
+
+      while ((input.indexOf("${")) != -1)
+      {
+         int from = input.indexOf("${");
+         int to = input.indexOf("}");
+         int dv = input.indexOf(":", from + 2);
+
+         if (dv != -1)
+         {
+            if (dv > to)
+               dv = -1;
+         }
+
+         String systemProperty = "";
+         String defaultValue = "";
+         String s = input.substring(from + 2, to);
+         if (dv == -1)
+         {
+            if ("/".equals(s))
+            {
+               systemProperty = File.separator;
+            }
+            else if (":".equals(s))
+            {
+               systemProperty = File.pathSeparator;
+            }
+            else
+            {
+               systemProperty = SecurityActions.getSystemProperty(s);
+            }
+         }
+         else
+         {
+            s = input.substring(from + 2, dv);
+            systemProperty = SecurityActions.getSystemProperty(s);
+            defaultValue = input.substring(dv + 1, to);
+         }
+         String prefix = "";
+         String postfix = "";
+
+         if (from != 0)
+         {
+            prefix = input.substring(0, from);
+         }
+
+         if (to + 1 < input.length() - 1)
+         {
+            postfix = input.substring(to + 1);
+         }
+
+         if (systemProperty != null && !systemProperty.trim().equals(""))
+         {
+            input = prefix + systemProperty + postfix;
+         }
+         else if (defaultValue != null && !defaultValue.trim().equals(""))
+         {
+            input = prefix + defaultValue + postfix;
+         }
+         else
+         {
+            input = prefix + postfix;
+            log.debugf("System property %s not set", s);
+         }
+      }
+      return input;
+   }
+
+   private static class SecurityActions
+   {
+      /**
+       * Constructor
+       */
+      private SecurityActions()
+      {
+      }
+
+      /**
+       * Get a system property
+       * @param name The property name
+       * @return The property value
+       */
+      static String getSystemProperty(final String name)
+      {
+         if (System.getSecurityManager() == null)
+         {
+            return System.getProperty(name);
+         }
+         else
+         {
+            return (String) AccessController.doPrivileged(new PrivilegedAction<Object>()
+            {
+               public Object run()
+               {
+                  return System.getProperty(name);
+               }
+            });
+         }
+      }
+   }
 }



More information about the jboss-cvs-commits mailing list