gt:                                 configMap.put(poolName, new HashMap<String, ModelNode>(0));
context: /*
   * 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.as.connector.subsystems.resourceadapters;
  
  import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
  import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
  import static org.jboss.as.connector.subsystems.common.pool.Constants.BACKGROUNDVALIDATION;
  import static org.jboss.as.connector.subsystems.common.pool.Constants.BACKGROUNDVALIDATIONMILLIS;
  import static org.jboss.as.connector.subsystems.common.pool.Constants.BLOCKING_TIMEOUT_WAIT_MILLIS;
  import static org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_DECREMENTER_CLASS;
  import static org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_DECREMENTER_PROPERTIES;
  import static org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_INCREMENTER_CLASS;
  import static org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_INCREMENTER_PROPERTIES;
  import static org.jboss.as.connector.subsystems.common.pool.Constants.IDLETIMEOUTMINUTES;
  import static org.jboss.as.connector.subsystems.common.pool.Constants.INITIAL_POOL_SIZE;
  import static org.jboss.as.connector.subsystems.common.pool.Constants.MAX_POOL_SIZE;
  import static org.jboss.as.connector.subsystems.common.pool.Constants.MIN_POOL_SIZE;
  import static org.jboss.as.connector.subsystems.common.pool.Constants.POOL_FAIR;
  import static org.jboss.as.connector.subsystems.common.pool.Constants.POOL_FLUSH_STRATEGY;
  import static org.jboss.as.connector.subsystems.common.pool.Constants.POOL_PREFILL;
  import static org.jboss.as.connector.subsystems.common.pool.Constants.POOL_USE_STRICT_MIN;
  import static org.jboss.as.connector.subsystems.common.pool.Constants.USE_FAST_FAIL;
  import static org.jboss.as.connector.subsystems.common.pool.Constants.VALIDATE_ON_MATCH;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.ALLOCATION_RETRY;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.ALLOCATION_RETRY_WAIT_MILLIS;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.APPLICATION;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.AUTHENTICATION_CONTEXT;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.AUTHENTICATION_CONTEXT_AND_APPLICATION;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.CLASS_NAME;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.CONFIG_PROPERTY_VALUE;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.CONNECTABLE;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.ELYTRON_ENABLED;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.ENABLED;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.ENLISTMENT;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.ENLISTMENT_TRACE;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.INTERLEAVING;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.JNDINAME;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.MCP;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.NOTXSEPARATEPOOL;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.NO_RECOVERY;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.PAD_XID;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.POOL_NAME_NAME;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.RECOVERLUGIN_CLASSNAME;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.RECOVERLUGIN_PROPERTIES;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.RECOVERY_AUTHENTICATION_CONTEXT;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.RECOVERY_CREDENTIAL_REFERENCE;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.RECOVERY_ELYTRON_ENABLED;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.RECOVERY_PASSWORD;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.RECOVERY_SECURITY_DOMAIN;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.RECOVERY_USERNAME;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.SAME_RM_OVERRIDE;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.SECURITY_DOMAIN;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.SECURITY_DOMAIN_AND_APPLICATION;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.SHARABLE;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.TRACKING;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.USE_CCM;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.USE_JAVA_CONTEXT;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.WRAP_XA_RESOURCE;
  import static org.jboss.as.connector.subsystems.resourceadapters.Constants.XA_RESOURCE_TIMEOUT;
  import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
  import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
  
  import java.util.EnumSet;
  import java.util.HashMap;
  import java.util.Map;
  
  import javax.xml.stream.XMLStreamException;
  
  import org.jboss.as.connector.metadata.api.common.Credential;
  import org.jboss.as.connector.metadata.api.common.Security;
  import org.jboss.as.connector.util.AbstractParser;
  import org.jboss.as.connector.util.ParserException;
  import org.jboss.as.controller.parsing.ParseUtils;
  import org.jboss.dmr.ModelNode;
  import org.jboss.jca.common.CommonBundle;
  import org.jboss.jca.common.api.metadata.common.Capacity;
  import org.jboss.jca.common.api.metadata.common.Pool;
  import org.jboss.jca.common.api.metadata.common.Recovery;
  import org.jboss.jca.common.api.metadata.common.TimeOut;
  import org.jboss.jca.common.api.metadata.common.Validation;
  import org.jboss.jca.common.api.metadata.common.XaPool;
  import org.jboss.jca.common.api.metadata.ds.DataSource;
  import org.jboss.jca.common.api.metadata.ds.DsPool;
  import org.jboss.jca.common.api.metadata.ds.XaDataSource;
  import org.jboss.jca.common.api.metadata.resourceadapter.Activation;
  import org.jboss.jca.common.api.metadata.resourceadapter.AdminObject;
  import org.jboss.jca.common.api.metadata.resourceadapter.ConnectionDefinition;
  import org.jboss.jca.common.api.validator.ValidateException;
  import org.jboss.logging.Messages;
  import org.jboss.staxmapper.XMLExtendedStreamReader;
  
  /**
   * A CommonIronJacamarParser.
   *
   * @author <a href="stefano.maestri@jboss.com">Stefano Maestri</a>
   */
  public abstract class CommonIronJacamarParser extends AbstractParser {
      /**
       * The bundle
       */
      private static CommonBundle bundle = Messages.getBundle(CommonBundle.class);
  
  
      protected void parseConfigProperties(final XMLExtendedStreamReader reader, final Map<String, ModelNode> map) throws XMLStreamException, ParserException {
          String name = rawAttributeText(reader, "name");
          final ModelNode operation = new ModelNode();
          operation.get(OP).set(ADD);
          String value = rawElementText(reader);
          CONFIG_PROPERTY_VALUE.parseAndSetParameter(value, operation, reader);
  
          if (map.containsKey(name)) {
              throw ParseUtils.unexpectedElement(reader);
          }
          map.put(name, operation);
      }
  
      /**
       * parse a single connection-definition tag
       *
       * @param reader the reader
       * @throws javax.xml.stream.XMLStreamException
       *                         XMLStreamException
       * @throws ParserException ParserException
       * @throws org.jboss.jca.common.api.validator.ValidateException
       *                         ValidateException
       */
      protected void parseConnectionDefinitions_3_0(final XMLExtendedStreamReader reader, final Map<String, ModelNode> map,
                                                final Map<String, HashMap<String, ModelNode>> configMap, final boolean isXa)
              throws XMLStreamException, ParserException, ValidateException {
  
  
          final ModelNode connectionDefinitionNode = new ModelNode();
          connectionDefinitionNode.get(OP).set(ADD);
  
          String poolName = null;
          String jndiName = null;
          int attributeSize = reader.getAttributeCount();
          boolean poolDefined = Boolean.FALSE;
  
          for (int i = 0; i < attributeSize; i++) {
              ConnectionDefinition.Attribute attribute = ConnectionDefinition.Attribute.forName(reader.getAttributeLocalName(i));
              String value = reader.getAttributeValue(i);
              switch (attribute) {
                  case ENABLED: {
                      ENABLED.parseAndSetParameter(value, connectionDefinitionNode, reader);
  
                      break;
                  }
                  case CONNECTABLE: {
                      CONNECTABLE.parseAndSetParameter(value, connectionDefinitionNode, reader);
  
                      break;
                  }
                  case TRACKING: {
                      TRACKING.parseAndSetParameter(value, connectionDefinitionNode, reader);
  
                      break;
                  }
                  case JNDI_NAME: {
                      jndiName = value;
                      JNDINAME.parseAndSetParameter(jndiName, connectionDefinitionNode, reader);
                      break;
                  }
                  case POOL_NAME: {
                      poolName = value;
                      break;
                  }
                  case USE_JAVA_CONTEXT: {
                      USE_JAVA_CONTEXT.parseAndSetParameter(value, connectionDefinitionNode, reader);
  
                      break;
                  }
  
                  case USE_CCM: {
                      USE_CCM.parseAndSetParameter(value, connectionDefinitionNode, reader);
                      break;
                  }
  
                  case SHARABLE: {
                      SHARABLE.parseAndSetParameter(value, connectionDefinitionNode, reader);
                      break;
                  }
  
                  case ENLISTMENT: {
                      ENLISTMENT.parseAndSetParameter(value, connectionDefinitionNode, reader);
                      break;
                  }
  
                  case CLASS_NAME: {
                      CLASS_NAME.parseAndSetParameter(value, connectionDefinitionNode, reader);
                      break;
                  }
                  default:
                      throw ParseUtils.unexpectedAttribute(reader, i);
              }
          }
          if (poolName == null || poolName.trim().equals("")) {
              if (jndiName != null && jndiName.trim().length() != 0) {
                  if (jndiName.contains("/")) {
                      poolName = jndiName.substring(jndiName.lastIndexOf("/") + 1);
                  } else {
                      poolName = jndiName.substring(jndiName.lastIndexOf(":") + 1);
                  }
              } else {
                  throw ParseUtils.missingRequired(reader, EnumSet.of(ConnectionDefinition.Attribute.JNDI_NAME));
              }
          }
  
  
          while (reader.hasNext()) {
              switch (reader.nextTag()) {
                  case END_ELEMENT: {
                      if (Activation.Tag.forName(reader.getLocalName()) == Activation.Tag.CONNECTION_DEFINITION) {
  
                          map.put(poolName, connectionDefinitionNode);
                          return;
                      } else {
                          if (ConnectionDefinition.Tag.forName(reader.getLocalName()) == ConnectionDefinition.Tag.UNKNOWN) {
                              throw ParseUtils.unexpectedEndElement(reader);
                          }
                      }
                      break;
                  }
                  case START_ELEMENT: {
                      switch (ConnectionDefinition.Tag.forName(reader.getLocalName())) {
                          case CONFIG_PROPERTY: {
                              if (!configMap.containsKey(poolName)) {
                                  configMap.put(poolName, new HashMap<String, ModelNode>(0));
                              }
                              parseConfigProperties(reader, configMap.get(poolName));
                              break;
                          }
                          case SECURITY: {
                              parseSecuritySettings(reader, connectionDefinitionNode);
                              break;
                          }
                          case TIMEOUT: {
                              parseTimeOut(reader, isXa, connectionDefinitionNode);
                              break;
                          }
                          case VALIDATION: {
                              parseValidation(reader, connectionDefinitionNode);
                              break;
                          }
                          case XA_POOL: {
                              if (!isXa) {
                                  throw ParseUtils.unexpectedElement(reader);
                              }
                              if (poolDefined) {
                                  throw new ParserException(bundle.multiplePools());
                              }
                              parseXaPool(reader, connectionDefinitionNode);
                              poolDefined = true;
                              break;
                          }
                          case POOL: {
                              if (isXa) {
                                  throw ParseUtils.unexpectedElement(reader);
                              }
                              if (poolDefined) {
                                  throw new ParserException(bundle.multiplePools());
                              }
                              parsePool(reader, connectionDefinitionNode);
                              poolDefined = true;
                              break;
                          }
                          case RECOVERY: {
                              parseRecovery(reader, connectionDefinitionNode);
                              break;
                          }
                          default:
                              throw ParseUtils.unexpectedElement(reader);
                      }
                      break;
                  }
              }
          }
          throw ParseUtils.unexpectedEndElement(reader);
  
      }
  
      /**
       * parse a single connection-definition tag
       *
       * @param reader the reader
       * @throws javax.xml.stream.XMLStreamException
       *                         XMLStreamException
       * @throws ParserException ParserException
       * @throws org.jboss.jca.common.api.validator.ValidateException
       *                         ValidateException
       */
      protected void parseConnectionDefinitions_4_0(final XMLExtendedStreamReader reader, final Map<String, ModelNode> map,
                                                    final Map<String, HashMap<String, ModelNode>> configMap, final boolean isXa)
              throws XMLStreamException, ParserException, ValidateException {
  
  
          final ModelNode connectionDefinitionNode = new ModelNode();
          connectionDefinitionNode.get(OP).set(ADD);
  
          String poolName = null;
          String jndiName = null;
          int attributeSize = reader.getAttributeCount();
          boolean poolDefined = Boolean.FALSE;
  
          for (int i = 0; i < attributeSize; i++) {
              ConnectionDefinition.Attribute attribute = ConnectionDefinition.Attribute.forName(reader.getAttributeLocalName(i));
              String value = reader.getAttributeValue(i);
              switch (attribute) {
                  case ENABLED: {
                      ENABLED.parseAndSetParameter(value, connectionDefinitionNode, reader);
  
                      break;
                  }
                  case CONNECTABLE: {
                      CONNECTABLE.parseAndSetParameter(value, connectionDefinitionNode, reader);
  
                      break;
                  }
                  case TRACKING: {
                      TRACKING.parseAndSetParameter(value, connectionDefinitionNode, reader);
  
                      break;
                  }
                  case JNDI_NAME: {
                      jndiName = value;
                      JNDINAME.parseAndSetParameter(jndiName, connectionDefinitionNode, reader);
                      break;
                  }
                  case POOL_NAME: {
                      poolName = value;
                      break;
                  }
                  case USE_JAVA_CONTEXT: {
                      USE_JAVA_CONTEXT.parseAndSetParameter(value, connectionDefinitionNode, reader);
  
                      break;
                  }
  
                  case USE_CCM: {
                      USE_CCM.parseAndSetParameter(value, connectionDefinitionNode, reader);
                      break;
                  }
  
                  case SHARABLE: {
                      SHARABLE.parseAndSetParameter(value, connectionDefinitionNode, reader);
                      break;
                  }
  
                  case ENLISTMENT: {
                      ENLISTMENT.parseAndSetParameter(value, connectionDefinitionNode, reader);
                      break;
                  }
  
                  case CLASS_NAME: {
                      CLASS_NAME.parseAndSetParameter(value, connectionDefinitionNode, reader);
                      break;
                  }
                  case MCP: {
                      MCP.parseAndSetParameter(value, connectionDefinitionNode, reader);
                      break;
                  }
                  case ENLISTMENT_TRACE:
                      ENLISTMENT_TRACE.parseAndSetParameter(value, connectionDefinitionNode, reader);
                      break;
                  default:
                      throw ParseUtils.unexpectedAttribute(reader, i);
              }
          }
          if (poolName == null || poolName.trim().equals("")) {
              if (jndiName != null && jndiName.trim().length() != 0) {
                  if (jndiName.contains("/")) {
                      poolName = jndiName.substring(jndiName.lastIndexOf("/") + 1);
                  } else {
                      poolName = jndiName.substring(jndiName.lastIndexOf(":") + 1);
                  }
              } else {
                  throw ParseUtils.missingRequired(reader, EnumSet.of(ConnectionDefinition.Attribute.JNDI_NAME));
              }
          }
  
  
          while (reader.hasNext()) {
              switch (reader.nextTag()) {
                  case END_ELEMENT: {
                      if (Activation.Tag.forName(reader.getLocalName()) == Activation.Tag.CONNECTION_DEFINITION) {
  
                          map.put(poolName, connectionDefinitionNode);
                          return;
                      } else {
                          if (ConnectionDefinition.Tag.forName(reader.getLocalName()) == ConnectionDefinition.Tag.UNKNOWN) {
                              throw ParseUtils.unexpectedEndElement(reader);
                          }
                      }
                      break;
                  }
                  case START_ELEMENT: {
                      switch (ConnectionDefinition.Tag.forName(reader.getLocalName())) {
                          case CONFIG_PROPERTY: {
                              if (!configMap.containsKey(poolName)) {
  