[jboss-cvs] JBossAS SVN: r110842 - in projects/jboss-jca/trunk/common/src: main/java/org/jboss/jca/common/metadata/ds and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Mar 7 07:46:45 EST 2011


Author: maeste
Date: 2011-03-07 07:46:44 -0500 (Mon, 07 Mar 2011)
New Revision: 110842

Added:
   projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/Extension.java
   projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/Recovery.java
   projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ds/DsParserForRecoveryTestCase.java
   projects/jboss-jca/trunk/common/src/test/resources/ds/unit/xa-resource-with-recovery-ds.xml
Removed:
   projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/JdbcAdapterExtension.java
Modified:
   projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/Validation.java
   projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/XaDataSource.java
   projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/DsParser.java
   projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/ValidationImpl.java
   projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/XADataSourceImpl.java
   projects/jboss-jca/trunk/common/src/main/resources/schema/datasources_1_0.xsd
Log:
JBJCA-509 xsd changes and metadata implementation

Copied: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/Extension.java (from rev 110841, projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/JdbcAdapterExtension.java)
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/Extension.java	                        (rev 0)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/Extension.java	2011-03-07 12:46:44 UTC (rev 110842)
@@ -0,0 +1,258 @@
+/*
+ * 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 file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.common.api.metadata.ds;
+
+import org.jboss.jca.common.api.metadata.JCAMetadata;
+import org.jboss.jca.common.api.metadata.ValidatableMetadata;
+import org.jboss.jca.common.api.validator.ValidateException;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * A JdbcAdapterExtension.
+ *
+ * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
+ *
+ */
+public final class Extension implements JCAMetadata, ValidatableMetadata
+{
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -6275984008991105644L;
+
+   private final String className;
+
+   private final Map<String, String> configPropertiesMap;
+
+   /**
+    * Create a new JdbcAdapterExtension.
+    *
+    * @param className the className
+    * @param configPropertiesMap configPropertiesMap
+    * @throws ValidateException ValidateException
+    */
+   public Extension(String className, Map<String, String> configPropertiesMap) throws ValidateException
+   {
+      super();
+      this.className = className;
+      if (configPropertiesMap != null)
+      {
+         this.configPropertiesMap = new HashMap<String, String>(configPropertiesMap.size());
+         this.configPropertiesMap.putAll(configPropertiesMap);
+      }
+      else
+      {
+         this.configPropertiesMap = Collections.emptyMap();
+      }
+      this.validate();
+   }
+
+   /**
+    * Get the className.
+    *
+    * @return the className.
+    */
+   public final String getClassName()
+   {
+      return className;
+   }
+
+   /**
+    * Get the configPropertiesMap.
+    *
+    * @return the configPropertiesMap.
+    */
+   public final Map<String, String> getConfigPropertiesMap()
+   {
+      return Collections.unmodifiableMap(configPropertiesMap);
+   }
+
+   @Override
+   public String toString()
+   {
+      return "JdbcAdapterExtension [className=" + className + ", configPropertiesMap=" + configPropertiesMap + "]";
+   }
+
+   @Override
+   public int hashCode()
+   {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((className == null) ? 0 : className.hashCode());
+      result = prime * result + ((configPropertiesMap == null) ? 0 : configPropertiesMap.hashCode());
+      return result;
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (this == obj)
+         return true;
+      if (obj == null)
+         return false;
+      if (!(obj instanceof Extension))
+         return false;
+      Extension other = (Extension) obj;
+      if (className == null)
+      {
+         if (other.className != null)
+            return false;
+      }
+      else if (!className.equals(other.className))
+         return false;
+      if (configPropertiesMap == null)
+      {
+         if (other.configPropertiesMap != null)
+            return false;
+      }
+      else if (!configPropertiesMap.equals(other.configPropertiesMap))
+         return false;
+      return true;
+   }
+
+   /**
+   *
+   * A Tag.
+   *
+   * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
+   *
+   */
+   public enum Tag
+   {
+      /** always first
+       *
+       */
+      UNKNOWN(null),
+
+      /**
+       * pool tag
+
+      /**
+      * config-property tag
+      */
+      CONFIG_PROPERTY("config-property");
+
+      private final String name;
+
+      /**
+       *
+       * Create a new Tag.
+       *
+       * @param name a name
+       */
+      Tag(final String name)
+      {
+         this.name = name;
+      }
+
+      /**
+       * Get the local name of this element.
+       *
+       * @return the local name
+       */
+      public String getLocalName()
+      {
+         return name;
+      }
+
+      private static final Map<String, Tag> MAP;
+
+      static
+      {
+         final Map<String, Tag> map = new HashMap<String, Tag>();
+         for (Tag element : values())
+         {
+            final String name = element.getLocalName();
+            if (name != null)
+               map.put(name, element);
+         }
+         MAP = map;
+      }
+
+      /**
+      *
+      * Static method to get enum instance given localName XsdString
+      *
+      * @param localName a XsdString used as localname (typically tag name as defined in xsd)
+      * @return the enum instance
+      */
+      public static Tag forName(String localName)
+      {
+         final Tag element = MAP.get(localName);
+         return element == null ? UNKNOWN : element;
+      }
+
+   }
+
+   /**
+    *
+    * A Attribute.
+    *
+    * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
+    *
+    */
+   public enum Attribute
+   {
+
+      /** class-name attribute
+      *
+      */
+      CLASS_NAME("class-name");
+
+      private final String name;
+
+      /**
+       *
+       * Create a new Tag.
+       *
+       * @param name a name
+       */
+      Attribute(final String name)
+      {
+         this.name = name;
+      }
+
+      /**
+       * Get the local name of this element.
+       *
+       * @return the local name
+       */
+      public String getLocalName()
+      {
+         return name;
+      }
+
+   }
+
+   @Override
+   public void validate() throws ValidateException
+   {
+      if (this.className == null || className.trim().length() == 0)
+         throw new ValidateException("className (xml attribute " + Attribute.CLASS_NAME + ") is required in " +
+                                     this.getClass().getCanonicalName());
+   }
+
+}
+

Deleted: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/JdbcAdapterExtension.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/JdbcAdapterExtension.java	2011-03-04 21:21:54 UTC (rev 110841)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/JdbcAdapterExtension.java	2011-03-07 12:46:44 UTC (rev 110842)
@@ -1,258 +0,0 @@
-/*
- * 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 file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY 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 along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jca.common.api.metadata.ds;
-
-import org.jboss.jca.common.api.metadata.JCAMetadata;
-import org.jboss.jca.common.api.metadata.ValidatableMetadata;
-import org.jboss.jca.common.api.validator.ValidateException;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- * A JdbcAdapterExtension.
- *
- * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
- *
- */
-public final class JdbcAdapterExtension implements JCAMetadata, ValidatableMetadata
-{
-
-   /** The serialVersionUID */
-   private static final long serialVersionUID = -6275984008991105644L;
-
-   private final String className;
-
-   private final Map<String, String> configPropertiesMap;
-
-   /**
-    * Create a new JdbcAdapterExtension.
-    *
-    * @param className the className
-    * @param configPropertiesMap configPropertiesMap
-    * @throws ValidateException ValidateException
-    */
-   public JdbcAdapterExtension(String className, Map<String, String> configPropertiesMap) throws ValidateException
-   {
-      super();
-      this.className = className;
-      if (configPropertiesMap != null)
-      {
-         this.configPropertiesMap = new HashMap<String, String>(configPropertiesMap.size());
-         this.configPropertiesMap.putAll(configPropertiesMap);
-      }
-      else
-      {
-         this.configPropertiesMap = Collections.emptyMap();
-      }
-      this.validate();
-   }
-
-   /**
-    * Get the className.
-    *
-    * @return the className.
-    */
-   public final String getClassName()
-   {
-      return className;
-   }
-
-   /**
-    * Get the configPropertiesMap.
-    *
-    * @return the configPropertiesMap.
-    */
-   public final Map<String, String> getConfigPropertiesMap()
-   {
-      return Collections.unmodifiableMap(configPropertiesMap);
-   }
-
-   @Override
-   public String toString()
-   {
-      return "JdbcAdapterExtension [className=" + className + ", configPropertiesMap=" + configPropertiesMap + "]";
-   }
-
-   @Override
-   public int hashCode()
-   {
-      final int prime = 31;
-      int result = 1;
-      result = prime * result + ((className == null) ? 0 : className.hashCode());
-      result = prime * result + ((configPropertiesMap == null) ? 0 : configPropertiesMap.hashCode());
-      return result;
-   }
-
-   @Override
-   public boolean equals(Object obj)
-   {
-      if (this == obj)
-         return true;
-      if (obj == null)
-         return false;
-      if (!(obj instanceof JdbcAdapterExtension))
-         return false;
-      JdbcAdapterExtension other = (JdbcAdapterExtension) obj;
-      if (className == null)
-      {
-         if (other.className != null)
-            return false;
-      }
-      else if (!className.equals(other.className))
-         return false;
-      if (configPropertiesMap == null)
-      {
-         if (other.configPropertiesMap != null)
-            return false;
-      }
-      else if (!configPropertiesMap.equals(other.configPropertiesMap))
-         return false;
-      return true;
-   }
-
-   /**
-   *
-   * A Tag.
-   *
-   * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
-   *
-   */
-   public enum Tag
-   {
-      /** always first
-       *
-       */
-      UNKNOWN(null),
-
-      /**
-       * pool tag
-
-      /**
-      * config-property tag
-      */
-      CONFIG_PROPERTY("config-property");
-
-      private final String name;
-
-      /**
-       *
-       * Create a new Tag.
-       *
-       * @param name a name
-       */
-      Tag(final String name)
-      {
-         this.name = name;
-      }
-
-      /**
-       * Get the local name of this element.
-       *
-       * @return the local name
-       */
-      public String getLocalName()
-      {
-         return name;
-      }
-
-      private static final Map<String, Tag> MAP;
-
-      static
-      {
-         final Map<String, Tag> map = new HashMap<String, Tag>();
-         for (Tag element : values())
-         {
-            final String name = element.getLocalName();
-            if (name != null)
-               map.put(name, element);
-         }
-         MAP = map;
-      }
-
-      /**
-      *
-      * Static method to get enum instance given localName XsdString
-      *
-      * @param localName a XsdString used as localname (typically tag name as defined in xsd)
-      * @return the enum instance
-      */
-      public static Tag forName(String localName)
-      {
-         final Tag element = MAP.get(localName);
-         return element == null ? UNKNOWN : element;
-      }
-
-   }
-
-   /**
-    *
-    * A Attribute.
-    *
-    * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
-    *
-    */
-   public enum Attribute
-   {
-
-      /** class-name attribute
-      *
-      */
-      CLASS_NAME("class-name");
-
-      private final String name;
-
-      /**
-       *
-       * Create a new Tag.
-       *
-       * @param name a name
-       */
-      Attribute(final String name)
-      {
-         this.name = name;
-      }
-
-      /**
-       * Get the local name of this element.
-       *
-       * @return the local name
-       */
-      public String getLocalName()
-      {
-         return name;
-      }
-
-   }
-
-   @Override
-   public void validate() throws ValidateException
-   {
-      if (this.className == null || className.trim().length() == 0)
-         throw new ValidateException("className (xml attribute " + Attribute.CLASS_NAME + ") is required in " +
-                                     this.getClass().getCanonicalName());
-   }
-
-}
-

Copied: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/Recovery.java (from rev 110841, projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/JdbcAdapterExtension.java)
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/Recovery.java	                        (rev 0)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/Recovery.java	2011-03-07 12:46:44 UTC (rev 110842)
@@ -0,0 +1,271 @@
+/*
+ * 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 file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.common.api.metadata.ds;
+
+import org.jboss.jca.common.api.metadata.JCAMetadata;
+import org.jboss.jca.common.api.metadata.ValidatableMetadata;
+import org.jboss.jca.common.api.validator.ValidateException;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * A Recovery.
+ *
+ * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
+ *
+ */
+public class Recovery implements JCAMetadata, ValidatableMetadata
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -7425365995463321893L;
+
+   private final DsSecurity security;
+
+   private final Extension plugin;
+
+   private final Boolean noRecovery;
+
+   /**
+    * Create a new Recovery.
+    *
+    * @param security security
+    * @param plugin plugin
+    * @param noRecovery niRecovery
+    * @throws ValidateException in case of not valid metadata creation
+    */
+   public Recovery(DsSecurity security, Extension plugin, Boolean noRecovery) throws ValidateException
+   {
+      super();
+      this.security = security;
+      this.plugin = plugin;
+      this.noRecovery = noRecovery;
+      this.validate();
+   }
+
+   /**
+    * Get the security.
+    *
+    * @return the security.
+    */
+   public final DsSecurity getSecurity()
+   {
+      return security;
+   }
+
+   /**
+    * Get the plugin.
+    *
+    * @return the plugin.
+    */
+   public final Extension getPlugin()
+   {
+      return plugin;
+   }
+
+   /**
+    * Get the noRecovery.
+    *
+    * @return the noRecovery.
+    */
+   public final Boolean getNoRecovery()
+   {
+      return noRecovery;
+   }
+
+   @Override
+   public void validate() throws ValidateException
+   {
+      // the only field not yet validated is a Boolean and all value are fine
+   }
+
+   @Override
+   public int hashCode()
+   {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((noRecovery == null) ? 0 : noRecovery.hashCode());
+      result = prime * result + ((plugin == null) ? 0 : plugin.hashCode());
+      result = prime * result + ((security == null) ? 0 : security.hashCode());
+      return result;
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (this == obj)
+         return true;
+      if (obj == null)
+         return false;
+      if (!(obj instanceof Recovery))
+         return false;
+      Recovery other = (Recovery) obj;
+      if (noRecovery == null)
+      {
+         if (other.noRecovery != null)
+            return false;
+      }
+      else if (!noRecovery.equals(other.noRecovery))
+         return false;
+      if (plugin == null)
+      {
+         if (other.plugin != null)
+            return false;
+      }
+      else if (!plugin.equals(other.plugin))
+         return false;
+      if (security == null)
+      {
+         if (other.security != null)
+            return false;
+      }
+      else if (!security.equals(other.security))
+         return false;
+      return true;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "Recovery [security=" + security + ", plugin=" + plugin + ", noRecovery=" + noRecovery + "]";
+   }
+
+   /**
+   *
+   * A Tag.
+   *
+   * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
+   *
+   */
+   public enum Tag
+   {
+      /** always first
+       *
+       */
+      UNKNOWN(null),
+
+      /**
+       * pool tag
+
+      /**
+      * config-property tag
+      */
+      SECURITY("security"),
+      /** plugin tag */
+
+      PLUGIN("plugin");
+
+      private final String name;
+
+      /**
+       *
+       * Create a new Tag.
+       *
+       * @param name a name
+       */
+      Tag(final String name)
+      {
+         this.name = name;
+      }
+
+      /**
+       * Get the local name of this element.
+       *
+       * @return the local name
+       */
+      public String getLocalName()
+      {
+         return name;
+      }
+
+      private static final Map<String, Tag> MAP;
+
+      static
+      {
+         final Map<String, Tag> map = new HashMap<String, Tag>();
+         for (Tag element : values())
+         {
+            final String name = element.getLocalName();
+            if (name != null)
+               map.put(name, element);
+         }
+         MAP = map;
+      }
+
+      /**
+      *
+      * Static method to get enum instance given localName XsdString
+      *
+      * @param localName a XsdString used as localname (typically tag name as defined in xsd)
+      * @return the enum instance
+      */
+      public static Tag forName(String localName)
+      {
+         final Tag element = MAP.get(localName);
+         return element == null ? UNKNOWN : element;
+      }
+
+   }
+
+   /**
+    *
+    * A Attribute.
+    *
+    * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
+    *
+    */
+   public enum Attribute
+   {
+
+      /** class-name attribute
+      *
+      */
+      NO_RECOVERY("no-recovery");
+
+      private final String name;
+
+      /**
+       *
+       * Create a new Tag.
+       *
+       * @param name a name
+       */
+      Attribute(final String name)
+      {
+         this.name = name;
+      }
+
+      /**
+       * Get the local name of this element.
+       *
+       * @return the local name
+       */
+      public String getLocalName()
+      {
+         return name;
+      }
+
+   }
+
+}
+

Modified: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/Validation.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/Validation.java	2011-03-04 21:21:54 UTC (rev 110841)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/Validation.java	2011-03-07 12:46:44 UTC (rev 110842)
@@ -42,7 +42,7 @@
     *
     * @return the validConnectionChecker
     */
-   public JdbcAdapterExtension getValidConnectionChecker();
+   public Extension getValidConnectionChecker();
 
    /**
     * Get the checkValidConnectionSql.
@@ -63,14 +63,14 @@
     *
     * @return the staleConnectionChecker
     */
-   public JdbcAdapterExtension getStaleConnectionChecker();
+   public Extension getStaleConnectionChecker();
 
    /**
     * Get the exceptionSorter
     *
     * @return the exceptionSorter
     */
-   public JdbcAdapterExtension getExceptionSorter();
+   public Extension getExceptionSorter();
 
 
    /**

Modified: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/XaDataSource.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/XaDataSource.java	2011-03-04 21:21:54 UTC (rev 110841)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/ds/XaDataSource.java	2011-03-07 12:46:44 UTC (rev 110842)
@@ -93,6 +93,13 @@
    public CommonXaPool getXaPool();
 
    /**
+    * Get the xaPool.
+    *
+    * @return the xaPool.
+    */
+   public Recovery getRecovery();
+
+   /**
    *
    * A Tag.
    *
@@ -154,8 +161,11 @@
       /**
        * xa-pool tag
        */
-      XA_POOL("xa-pool");
+      XA_POOL("xa-pool"),
 
+      /** recovery tag */
+      RECOVERY("recovery");
+
       private final String name;
 
       /**

Modified: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/DsParser.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/DsParser.java	2011-03-04 21:21:54 UTC (rev 110841)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/DsParser.java	2011-03-07 12:46:44 UTC (rev 110842)
@@ -26,7 +26,8 @@
 import org.jboss.jca.common.api.metadata.ds.DataSource;
 import org.jboss.jca.common.api.metadata.ds.DataSources;
 import org.jboss.jca.common.api.metadata.ds.DsSecurity;
-import org.jboss.jca.common.api.metadata.ds.JdbcAdapterExtension;
+import org.jboss.jca.common.api.metadata.ds.Extension;
+import org.jboss.jca.common.api.metadata.ds.Recovery;
 import org.jboss.jca.common.api.metadata.ds.Statement;
 import org.jboss.jca.common.api.metadata.ds.Statement.TrackStatementsEnum;
 import org.jboss.jca.common.api.metadata.ds.TimeOut;
@@ -184,6 +185,7 @@
       String urlSelectorStrategyClassName = null;
       String newConnectionSql = null;
       CommonXaPool xaPool = null;
+      Recovery recovery = null;
 
       String xaDataSourceClass = null;
       String module = null;
@@ -238,7 +240,7 @@
                                               statementSettings, validationSettings, urlDelimiter,
                                               urlSelectorStrategyClassName, useJavaContext, poolName, enabled,
                                               jndiName, spy, xaDataSourceProperty, xaDataSourceClass, module,
-                                              newConnectionSql, xaPool);
+                                              newConnectionSql, xaPool, recovery);
                }
                else
                {
@@ -300,6 +302,10 @@
                      validationSettings = parseValidationSetting(reader);
                      break;
                   }
+                  case RECOVERY : {
+                     recovery = parseRecovery(reader);
+                     break;
+                  }
                   default :
                      throw new ParserException("Unexpected element:" + reader.getLocalName());
                }
@@ -510,11 +516,11 @@
       boolean validateOnMatch = false;
       boolean useFastFail = false;
       Long backgroundValidationMinutes = null;
-      JdbcAdapterExtension staleConnectionChecker = null;
+      Extension staleConnectionChecker = null;
       boolean backgroundValidation = false;
       String checkValidConnectionSql = null;
-      JdbcAdapterExtension validConnectionChecker = null;
-      JdbcAdapterExtension exceptionSorter = null;
+      Extension validConnectionChecker = null;
+      Extension exceptionSorter = null;
 
       while (reader.hasNext())
       {
@@ -555,11 +561,11 @@
                      break;
                   }
                   case EXCEPTIONSORTER : {
-                     exceptionSorter = parseJdbcAdapterExtension(reader, currTag);
+                     exceptionSorter = parseExtension(reader, currTag);
                      break;
                   }
                   case STALECONNECTIONCHECKER : {
-                     staleConnectionChecker = parseJdbcAdapterExtension(reader, currTag);
+                     staleConnectionChecker = parseExtension(reader, currTag);
                      break;
                   }
                   case USEFASTFAIL : {
@@ -571,7 +577,7 @@
                      break;
                   }
                   case VALIDCONNECTIONCHECKER : {
-                     validConnectionChecker = parseJdbcAdapterExtension(reader, currTag);
+                     validConnectionChecker = parseExtension(reader, currTag);
                      break;
                   }
                   default :
@@ -584,14 +590,75 @@
       throw new ParserException("Reached end of xml document unexpectedly");
    }
 
-   private JdbcAdapterExtension parseJdbcAdapterExtension(XMLStreamReader reader, Validation.Tag enclosingTag)
+   private Recovery parseRecovery(XMLStreamReader reader)
       throws XMLStreamException, ParserException, ValidateException
    {
 
+      Boolean noRecovery = null;
+      DsSecurity security = null;
+      Extension plugin = null;
+
+      for (Recovery.Attribute attribute : Recovery.Attribute.values())
+      {
+         switch (attribute)
+         {
+            case NO_RECOVERY : {
+               noRecovery = attributeAsBoolean(reader, attribute.getLocalName(), false);
+               break;
+            }
+            default :
+               break;
+         }
+      }
+
+      while (reader.hasNext())
+      {
+         switch (reader.nextTag())
+         {
+            case END_ELEMENT : {
+               if (XaDataSource.Tag.forName(reader.getLocalName()) == XaDataSource.Tag.RECOVERY)
+               {
+                  return new Recovery(security, plugin, noRecovery);
+               }
+               else
+               {
+                  if (Recovery.Tag.forName(reader.getLocalName()) == Recovery.Tag.UNKNOWN)
+                  {
+                     throw new ParserException("unexpected end tag" + reader.getLocalName());
+                  }
+               }
+               break;
+            }
+            case START_ELEMENT : {
+               Recovery.Tag tag = Recovery.Tag.forName(reader.getLocalName());
+               switch (tag)
+               {
+                  case SECURITY : {
+                     security = parseDsSecuritySettings(reader);
+                     break;
+                  }
+                  case PLUGIN : {
+                     plugin = parseExtension(reader, tag);
+                     break;
+                  }
+                  default :
+                     throw new ParserException("Unexpected element:" + reader.getLocalName());
+               }
+               break;
+            }
+         }
+      }
+      throw new ParserException("Reached end of xml document unexpectedly");
+   }
+
+   private Extension parseExtension(XMLStreamReader reader, Validation.Tag enclosingTag)
+      throws XMLStreamException, ParserException, ValidateException
+   {
+
       String className = null;
       Map<String, String> properties = null;
 
-      for (JdbcAdapterExtension.Attribute attribute : JdbcAdapterExtension.Attribute.values())
+      for (Extension.Attribute attribute : Extension.Attribute.values())
       {
          switch (attribute)
          {
@@ -617,11 +684,11 @@
                                                enclosingTag.getLocalName());
                   }
 
-                  return new JdbcAdapterExtension(className, properties);
+                  return new Extension(className, properties);
                }
                else
                {
-                  if (JdbcAdapterExtension.Tag.forName(reader.getLocalName()) == JdbcAdapterExtension.Tag.UNKNOWN)
+                  if (Extension.Tag.forName(reader.getLocalName()) == Extension.Tag.UNKNOWN)
                   {
                      throw new ParserException("unexpected end tag" + reader.getLocalName());
                   }
@@ -629,13 +696,15 @@
                break;
             }
             case START_ELEMENT : {
-               switch (JdbcAdapterExtension.Tag.forName(reader.getLocalName()))
+               switch (Extension.Tag.forName(reader.getLocalName()))
                {
                   case CONFIG_PROPERTY : {
                      if (properties == null) properties = new HashMap<String, String>();
                      properties.put(attributeAsString(reader, "name"), elementAsString(reader));
                      break;
                   }
+                  default :
+                     throw new ParserException("Unexpected element:" + reader.getLocalName());
                }
                break;
             }
@@ -645,7 +714,69 @@
    }
 
 
+   private Extension parseExtension(XMLStreamReader reader, Recovery.Tag enclosingTag)
+      throws XMLStreamException, ParserException, ValidateException
+   {
 
+      String className = null;
+      Map<String, String> properties = null;
+
+      for (Extension.Attribute attribute : Extension.Attribute.values())
+      {
+         switch (attribute)
+         {
+            case CLASS_NAME : {
+               className = attributeAsString(reader, attribute.getLocalName());
+               break;
+            }
+            default :
+               break;
+         }
+      }
+
+      while (reader.hasNext())
+      {
+         switch (reader.nextTag())
+         {
+            case END_ELEMENT : {
+               if (Recovery.Tag.forName(reader.getLocalName()) == enclosingTag)
+               {
+                  if (className == null)
+                  {
+                     throw new ParserException("mandatory class-name attribute missing in " +
+                                               enclosingTag.getLocalName());
+                  }
+
+                  return new Extension(className, properties);
+               }
+               else
+               {
+                  if (Extension.Tag.forName(reader.getLocalName()) == Extension.Tag.UNKNOWN)
+                  {
+                     throw new ParserException("unexpected end tag" + reader.getLocalName());
+                  }
+               }
+               break;
+            }
+            case START_ELEMENT : {
+               switch (Extension.Tag.forName(reader.getLocalName()))
+               {
+                  case CONFIG_PROPERTY : {
+                     if (properties == null)
+                        properties = new HashMap<String, String>();
+                     properties.put(attributeAsString(reader, "name"), elementAsString(reader));
+                     break;
+                  }
+                  default :
+                     throw new ParserException("Unexpected element:" + reader.getLocalName());
+               }
+               break;
+            }
+         }
+      }
+      throw new ParserException("Reached end of xml document unexpectedly");
+   }
+
    private TimeOut parseTimeOutSettings(XMLStreamReader reader) throws XMLStreamException, ParserException,
       ValidateException
    {

Modified: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/ValidationImpl.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/ValidationImpl.java	2011-03-04 21:21:54 UTC (rev 110841)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/ValidationImpl.java	2011-03-07 12:46:44 UTC (rev 110842)
@@ -21,7 +21,7 @@
  */
 package org.jboss.jca.common.metadata.ds;
 
-import org.jboss.jca.common.api.metadata.ds.JdbcAdapterExtension;
+import org.jboss.jca.common.api.metadata.ds.Extension;
 import org.jboss.jca.common.api.metadata.ds.Validation;
 import org.jboss.jca.common.api.validator.ValidateException;
 
@@ -38,15 +38,15 @@
    /** The serialVersionUID */
    private static final long serialVersionUID = 7816717816552118419L;
 
-   private final JdbcAdapterExtension validConnectionChecker;
+   private final Extension validConnectionChecker;
 
    private final String checkValidConnectionSql;
 
    private final Boolean validateOnMatch;
 
-   private final JdbcAdapterExtension staleConnectionChecker;
+   private final Extension staleConnectionChecker;
 
-   private final JdbcAdapterExtension exceptionSorter;
+   private final Extension exceptionSorter;
 
    /**
     * Create a new ValidationImpl.
@@ -62,8 +62,8 @@
     * @throws ValidateException ValidateException
     */
    public ValidationImpl(Boolean backgroundValidation, Long backgroundValidationMinutes, Boolean useFastFail,
-      JdbcAdapterExtension validConnectionChecker, String checkValidConnectionSql, Boolean validateOnMatch,
-      JdbcAdapterExtension staleConnectionChecker, JdbcAdapterExtension exceptionSorter) throws ValidateException
+      Extension validConnectionChecker, String checkValidConnectionSql, Boolean validateOnMatch,
+      Extension staleConnectionChecker, Extension exceptionSorter) throws ValidateException
    {
       super(backgroundValidation, backgroundValidationMinutes, useFastFail);
       this.validConnectionChecker = validConnectionChecker;
@@ -101,7 +101,7 @@
     *
     * @return the validConnectionChecker.
     */
-   public final JdbcAdapterExtension getValidConnectionChecker()
+   public final Extension getValidConnectionChecker()
    {
       return validConnectionChecker;
    }
@@ -121,7 +121,7 @@
     *
     * @return the staleConnectionChecker.
     */
-   public final JdbcAdapterExtension getStaleConnectionChecker()
+   public final Extension getStaleConnectionChecker()
    {
       return staleConnectionChecker;
    }
@@ -131,7 +131,7 @@
     *
     * @return the exceptionSorter.
     */
-   public final JdbcAdapterExtension getExceptionSorter()
+   public final Extension getExceptionSorter()
    {
       return exceptionSorter;
    }

Modified: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/XADataSourceImpl.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/XADataSourceImpl.java	2011-03-04 21:21:54 UTC (rev 110841)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/ds/XADataSourceImpl.java	2011-03-07 12:46:44 UTC (rev 110842)
@@ -23,6 +23,7 @@
 
 import org.jboss.jca.common.api.metadata.common.CommonXaPool;
 import org.jboss.jca.common.api.metadata.ds.DsSecurity;
+import org.jboss.jca.common.api.metadata.ds.Recovery;
 import org.jboss.jca.common.api.metadata.ds.Statement;
 import org.jboss.jca.common.api.metadata.ds.TimeOut;
 import org.jboss.jca.common.api.metadata.ds.TransactionIsolation;
@@ -56,6 +57,8 @@
 
    private final CommonXaPool xaPool;
 
+   private final Recovery recovery;
+
    /**
     * Create a new XADataSourceImpl.
     *
@@ -76,13 +79,14 @@
     * @param module module
     * @param newConnectionSql newConnectionSql
     * @param xaPool xaPool
+    * @param recovery recovery
     * @throws ValidateException ValidateException
     */
    public XADataSourceImpl(TransactionIsolation transactionIsolation, TimeOut timeOut, DsSecurity security,
       Statement statement, Validation validation, String urlDelimiter, String urlSelectorStrategyClassName,
       boolean useJavaContext, String poolName, boolean enabled, String jndiName, boolean spy,
       Map<String, String> xaDataSourceProperty, String xaDataSourceClass, String module, String newConnectionSql,
-      CommonXaPool xaPool) throws ValidateException
+      CommonXaPool xaPool, Recovery recovery) throws ValidateException
    {
       super(transactionIsolation, timeOut, security, statement, validation, urlDelimiter,
             urlSelectorStrategyClassName, useJavaContext, poolName, enabled, jndiName, spy);
@@ -99,6 +103,7 @@
       this.module = module;
       this.newConnectionSql = newConnectionSql;
       this.xaPool = xaPool;
+      this.recovery = recovery;
       this.validate();
    }
 
@@ -272,4 +277,10 @@
                                      ") is required ");
 
    }
+
+   @Override
+   public Recovery getRecovery()
+   {
+      return recovery;
+   }
 }

Modified: projects/jboss-jca/trunk/common/src/main/resources/schema/datasources_1_0.xsd
===================================================================
--- projects/jboss-jca/trunk/common/src/main/resources/schema/datasources_1_0.xsd	2011-03-04 21:21:54 UTC (rev 110841)
+++ projects/jboss-jca/trunk/common/src/main/resources/schema/datasources_1_0.xsd	2011-03-07 12:46:44 UTC (rev 110842)
@@ -291,6 +291,7 @@
           </xs:documentation>
         </xs:annotation>
       </xs:element>
+      <xs:element name="recovery" type="recoverType" minOccurs="0" maxOccurs="1"></xs:element>
     </xs:sequence>
     <xs:attributeGroup ref="common-datasourceAttributes" />
   </xs:complexType>
@@ -371,7 +372,7 @@
   </xs:complexType>
   <xs:complexType name="validationType">
     <xs:sequence>
-      <xs:element name="valid-connection-checker" type="jdbc-adapter-extensionType" minOccurs="0">
+      <xs:element name="valid-connection-checker" type="extensionType" minOccurs="0">
         <xs:annotation>
           <xs:documentation>
             <![CDATA[[
@@ -438,7 +439,7 @@
           </xs:documentation>
         </xs:annotation>
       </xs:element>
-      <xs:element minOccurs="0" name="stale-connection-checker" type="jdbc-adapter-extensionType">
+      <xs:element minOccurs="0" name="stale-connection-checker" type="extensionType">
         <xs:annotation>
           <xs:documentation>
             <![CDATA[[
@@ -451,7 +452,7 @@
           </xs:documentation>
         </xs:annotation>
       </xs:element>
-      <xs:element name="exception-sorter" type="jdbc-adapter-extensionType" minOccurs="0">
+      <xs:element name="exception-sorter" type="extensionType" minOccurs="0">
         <xs:annotation>
           <xs:documentation>
             <![CDATA[[
@@ -748,7 +749,7 @@
     </xs:sequence>
    </xs:complexType>
 
-  <xs:complexType name="jdbc-adapter-extensionType">
+  <xs:complexType name="extensionType">
     <xs:sequence>
       <xs:element name="config-property" type="config-propertyType"></xs:element>
     </xs:sequence>
@@ -777,4 +778,38 @@
       </xs:extension>
     </xs:simpleContent>
   </xs:complexType>
+  <xs:complexType name="recoverType">
+    <xs:sequence>
+      <xs:element name="security" type="securityType">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Specifies the security options used when creating a connection during recovery.
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="plugin" type="extensionType">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Specifies the extension plugin used in spi (core.spi.xa) 
+              which can be implemented by various plugins to provide better feedback to the XA recovery system.
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+    <xs:attribute name="no-recovery" type="xs:boolean" default="false" use="optional">
+      <xs:annotation>
+        <xs:documentation>
+          <![CDATA[[
+            Specify if the xa-datasource should be excluded from recovery.
+            Default false.
+           ]]>
+        </xs:documentation>
+      </xs:annotation>
+    </xs:attribute>
+  </xs:complexType>
+  
 </xs:schema>

Added: projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ds/DsParserForRecoveryTestCase.java
===================================================================
--- projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ds/DsParserForRecoveryTestCase.java	                        (rev 0)
+++ projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ds/DsParserForRecoveryTestCase.java	2011-03-07 12:46:44 UTC (rev 110842)
@@ -0,0 +1,123 @@
+/*
+ * 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 file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.common.metadata.ds;
+
+import org.jboss.jca.common.api.metadata.ds.DataSources;
+import org.jboss.jca.common.api.metadata.ds.DsSecurity;
+import org.jboss.jca.common.api.metadata.ds.Extension;
+import org.jboss.jca.common.api.metadata.ds.Recovery;
+import org.jboss.jca.common.api.metadata.ds.XaDataSource;
+import org.jboss.jca.common.api.validator.ValidateException;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Matchers.isNull;
+
+/**
+ *
+ * A DsParserForMinimalFileTestCase.
+ *
+ * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
+ *
+ */
+public class DsParserForRecoveryTestCase
+{
+
+   private static DsParser parser;
+
+   /**
+   *
+   * beforeClass method
+   *
+   * @throws Exception in casae of file not found
+   */
+   @BeforeClass
+   public static void beforeClass() throws Exception
+   {
+      parser = new DsParser();
+      //this property is set just to make possible property substitution defined in test resources.
+      //but property substitution is not the goal of this test case see DsParserForTemplateReplaceTestCase for that
+      System.setProperty("jboss.server.data.dir", "/tmp");
+   }
+
+   /**
+    *
+    * shouldThrowValidateExceptionIfNoDriverHasBeenSpecified
+    *
+    * @throws Exception test passes if a {@link ValidateException} has been
+    * thrown
+    */
+   @Test()
+   public void shouldParseXaDsWithRecoveryInformation() throws Exception
+   {
+
+      //given
+      File xmlFile = new File(Thread.currentThread().getContextClassLoader()
+         .getResource("ds/unit/xa-resource-with-recovery-ds.xml")
+         .toURI());
+      //when
+      DataSources datasources = doParse(xmlFile);
+      XaDataSource ds = datasources.getXaDataSource().get(0);
+      Recovery recovery = ds.getRecovery();
+      assertThat(recovery, not(isNull()));
+      assertThat(recovery.getNoRecovery(), is(false));
+      DsSecurity security = recovery.getSecurity();
+      Extension plugin = recovery.getPlugin();
+      assertThat(security.getUserName(), is("myUserName"));
+      assertThat(security.getPassword(), is("myPassword"));
+      assertThat(security.getSecurityDomain(), is("mySecurityDomain"));
+      assertThat(plugin.getClassName(), is("myClassName"));
+      assertThat(plugin.getConfigPropertiesMap().size(), is(1));
+      assertThat(plugin.getConfigPropertiesMap().get("MyProperty"), is("MyPropertyValue"));
+
+      //then
+   }
+
+   private DataSources doParse(File xmlFile) throws FileNotFoundException, Exception, IOException, ValidateException
+   {
+      FileInputStream is = null;
+
+      try
+      {
+         is = new FileInputStream(xmlFile);
+         //when
+         DataSources ds = parser.parse(is);
+         return ds;
+      }
+      finally
+      {
+         if (is != null)
+            is.close();
+      }
+   }
+
+
+}

Added: projects/jboss-jca/trunk/common/src/test/resources/ds/unit/xa-resource-with-recovery-ds.xml
===================================================================
--- projects/jboss-jca/trunk/common/src/test/resources/ds/unit/xa-resource-with-recovery-ds.xml	                        (rev 0)
+++ projects/jboss-jca/trunk/common/src/test/resources/ds/unit/xa-resource-with-recovery-ds.xml	2011-03-07 12:46:44 UTC (rev 110842)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ===================================================================== -->
+<!-- ATTENTION: DO NOT FORGET TO SET Pad=true IN transaction-service.xml -->
+<!-- ===================================================================== -->
+<datasources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="http://www.jboss.org/jee/schema/ironjacamar/datasources_1_0.xsd">
+  <xa-datasource jndi-name="XAOracleDS" pool-name="XAOracleDS">
+    <xa-datasource-property name="URL">jdbc:oracle:oci8:@tc</xa-datasource-property>
+    <xa-datasource-property name="User">scott</xa-datasource-property>
+    <xa-datasource-property name="Password">tiger</xa-datasource-property>
+    <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
+    <timeout>
+      <!-- ********************************************** -->
+      <!-- THIS FIELD IS CAUSING THE FAIL OF RELATED TEST -->
+      <!-- ********************************************** -->
+      <xa-resource-timeout>1</xa-resource-timeout>
+    </timeout>
+    <recovery>
+      <security>
+         <user-name>myUserName</user-name>
+         <password>myPassword</password>
+         <security-domain>mySecurityDomain</security-domain>
+      </security>
+      <plugin class-name="myClassName">
+         <config-property name="MyProperty">MyPropertyValue</config-property>
+      </plugin>
+    </recovery>
+  </xa-datasource>
+</datasources>



More information about the jboss-cvs-commits mailing list