public static ModifiableConnDef buildConnectionDefinitionObject(ModelNode operation)
      throws ValidateException {
    Map<String, String> configProperties = new HashMap<String, String>(0);
    //        if (operation.hasDefined(CONFIG_PROPERTIES.getName())) {
    //            configProperties = new HashMap<String,
    // String>(operation.get(CONFIG_PROPERTIES.getName()).asList().size());
    //            for (ModelNode property : operation.get(CONFIG_PROPERTIES.getName()).asList()) {
    //                configProperties.put(property.asProperty().getName(),
    // property.asProperty().getValue().asString());
    //            }
    //        }
    String className = getStringIfSetOrGetDefault(operation, CLASS_NAME.getName(), null);
    String jndiName = getStringIfSetOrGetDefault(operation, JNDINAME.getName(), null);
    String poolName = getStringIfSetOrGetDefault(operation, POOL_NAME.getName(), null);
    boolean enabled = getBooleanIfSetOrGetDefault(operation, ENABLED.getName(), Defaults.ENABLED);
    boolean useJavaContext =
        getBooleanIfSetOrGetDefault(
            operation, USE_JAVA_CONTEXT.getName(), Defaults.USE_JAVA_CONTEXT);
    boolean useCcm = getBooleanIfSetOrGetDefault(operation, USE_CCM.getName(), Defaults.USE_CCM);

    Integer maxPoolSize =
        getIntIfSetOrGetDefault(operation, MAX_POOL_SIZE.getName(), Defaults.MAX_POOL_SIZE);
    Integer minPoolSize =
        getIntIfSetOrGetDefault(operation, MIN_POOL_SIZE.getName(), Defaults.MIN_POOL_SIZE);
    boolean prefill =
        getBooleanIfSetOrGetDefault(operation, POOL_PREFILL.getName(), Defaults.PREFILL);
    boolean useStrictMin =
        getBooleanIfSetOrGetDefault(
            operation, POOL_USE_STRICT_MIN.getName(), Defaults.USE_STRICT_MIN);
    final FlushStrategy flushStrategy =
        operation.hasDefined(POOL_FLUSH_STRATEGY.getName())
            ? FlushStrategy.forName(operation.get(POOL_FLUSH_STRATEGY.getName()).asString())
            : Defaults.FLUSH_STRATEGY;

    Integer allocationRetry = getIntIfSetOrGetDefault(operation, ALLOCATION_RETRY.getName(), null);
    Long allocationRetryWaitMillis =
        getLongIfSetOrGetDefault(operation, ALLOCATION_RETRY_WAIT_MILLIS.getName(), null);
    Long blockingTimeoutMillis =
        getLongIfSetOrGetDefault(operation, BLOCKING_TIMEOUT_WAIT_MILLIS.getName(), null);
    Long idleTimeoutMinutes =
        getLongIfSetOrGetDefault(operation, IDLETIMEOUTMINUTES.getName(), null);
    Integer xaResourceTimeout =
        getIntIfSetOrGetDefault(operation, XA_RESOURCE_TIMEOUT.getName(), null);
    CommonTimeOut timeOut =
        new CommonTimeOutImpl(
            blockingTimeoutMillis,
            idleTimeoutMinutes,
            allocationRetry,
            allocationRetryWaitMillis,
            xaResourceTimeout);
    CommonPool pool =
        new CommonPoolImpl(minPoolSize, maxPoolSize, prefill, useStrictMin, flushStrategy);

    String securityDomain = getStringIfSetOrGetDefault(operation, SECURITY_DOMAIN.getName(), null);
    String securityDomainAndApplication =
        getStringIfSetOrGetDefault(operation, SECURITY_DOMAIN_AND_APPLICATION.getName(), null);
    Boolean application = getBooleanIfSetOrGetDefault(operation, APPLICATION.getName(), null);

    CommonSecurity security = null;

    if (securityDomain != null && securityDomainAndApplication != null && application != null) {
      if (application == null) application = Defaults.APPLICATION_MANAGED_SECURITY;
      security = new CommonSecurityImpl(securityDomain, securityDomainAndApplication, application);
    }

    Long backgroundValidationMillis =
        getLongIfSetOrGetDefault(operation, BACKGROUNDVALIDATIONMILLIS.getName(), null);
    boolean backgroundValidation =
        getBooleanIfSetOrGetDefault(
            operation, BACKGROUNDVALIDATION.getName(), Defaults.BACKGROUND_VALIDATION);
    boolean useFastFail =
        getBooleanIfSetOrGetDefault(operation, USE_FAST_FAIL.getName(), Defaults.USE_FAST_FAIl);
    CommonValidation validation =
        new CommonValidationImpl(backgroundValidation, backgroundValidationMillis, useFastFail);
    final String recoveryUsername =
        getStringIfSetOrGetDefault(operation, RECOVERY_USERNAME.getName(), null);
    String recoveryPassword =
        getStringIfSetOrGetDefault(operation, RECOVERY_PASSWORD.getName(), null);

    if (VaultUtil.isVaultFormat(recoveryPassword)) {
      try {
        recoveryPassword = VaultUtil.getValueAsString(recoveryPassword);
      } catch (SecurityVaultException e) {
        throw new RuntimeException(e); // TODO: use bundle from IJ
      }
    }
    final String recoverySecurityDomain =
        getStringIfSetOrGetDefault(operation, RECOVERY_SECURITY_DOMAIN.getName(), null);

    final Credential credential =
        new CredentialImpl(recoveryUsername, recoveryPassword, recoverySecurityDomain);

    final Extension recoverPlugin =
        extractExtension(
            operation, RECOVERLUGIN_CLASSNAME.getName(), RECOVERLUGIN_PROPERTIES.getName());
    final boolean noRecovery = getBooleanIfSetOrGetDefault(operation, NO_RECOVERY.getName(), false);
    Recovery recovery = new Recovery(credential, recoverPlugin, noRecovery);
    ModifiableConnDef connectionDefinition =
        new ModifiableConnDef(
            configProperties,
            className,
            jndiName,
            poolName,
            enabled,
            useJavaContext,
            useCcm,
            pool,
            timeOut,
            validation,
            security,
            recovery);

    return connectionDefinition;
  }
  static ModifiableXaDataSource xaFrom(
      final OperationContext operationContext, final ModelNode dataSourceNode, final String dsName)
      throws OperationFailedException, ValidateException {
    final Map<String, String> xaDataSourceProperty;
    xaDataSourceProperty = Collections.emptyMap();

    final String xaDataSourceClass =
        getStringIfSetOrGetDefault(dataSourceNode, XADATASOURCECLASS, null);
    final String jndiName = getStringIfSetOrGetDefault(dataSourceNode, JNDINAME, null);
    final String module = getStringIfSetOrGetDefault(dataSourceNode, DATASOURCE_DRIVER, null);
    final String newConnectionSql =
        getStringIfSetOrGetDefault(dataSourceNode, NEW_CONNECTION_SQL, null);
    final String poolName = dsName;
    final String urlDelimiter = getStringIfSetOrGetDefault(dataSourceNode, URL_DELIMITER, null);
    final String urlSelectorStrategyClassName =
        getStringIfSetOrGetDefault(dataSourceNode, URL_SELECTOR_STRATEGY_CLASS_NAME, null);
    final Boolean useJavaContext =
        getBooleanIfSetOrGetDefault(dataSourceNode, USE_JAVA_CONTEXT, Defaults.USE_JAVA_CONTEXT);
    final Boolean enabled = getBooleanIfSetOrGetDefault(dataSourceNode, ENABLED, Defaults.ENABLED);
    final Integer maxPoolSize =
        getIntIfSetOrGetDefault(dataSourceNode, MAX_POOL_SIZE, Defaults.MAX_POOL_SIZE);
    final Integer minPoolSize =
        getIntIfSetOrGetDefault(dataSourceNode, MIN_POOL_SIZE, Defaults.MIN_POOL_SIZE);
    final Boolean prefill =
        getBooleanIfSetOrGetDefault(dataSourceNode, POOL_PREFILL, Defaults.PREFILL);
    final Boolean useStrictMin =
        getBooleanIfSetOrGetDefault(dataSourceNode, POOL_USE_STRICT_MIN, Defaults.USE_STRICT_MIN);
    final Boolean interleaving =
        getBooleanIfSetOrGetDefault(dataSourceNode, INTERLEAVING, Defaults.INTERLEAVING);
    final Boolean noTxSeparatePool =
        getBooleanIfSetOrGetDefault(dataSourceNode, NOTXSEPARATEPOOL, Defaults.NO_TX_SEPARATE_POOL);
    final Boolean padXid = getBooleanIfSetOrGetDefault(dataSourceNode, PAD_XID, Defaults.PAD_XID);
    final Boolean isSameRmOverride =
        getBooleanIfSetOrGetDefault(dataSourceNode, SAME_RM_OVERRIDE, Defaults.IS_SAME_RM_OVERRIDE);
    final Boolean wrapXaDataSource =
        getBooleanIfSetOrGetDefault(dataSourceNode, WRAP_XA_RESOURCE, Defaults.WRAP_XA_RESOURCE);
    final FlushStrategy flushStrategy =
        dataSourceNode.hasDefined(POOL_FLUSH_STRATEGY.getName())
            ? FlushStrategy.forName(dataSourceNode.get(POOL_FLUSH_STRATEGY.getName()).asString())
            : Defaults.FLUSH_STRATEGY;

    final CommonXaPool xaPool =
        new CommonXaPoolImpl(
            minPoolSize,
            maxPoolSize,
            prefill,
            useStrictMin,
            flushStrategy,
            isSameRmOverride,
            interleaving,
            padXid,
            wrapXaDataSource,
            noTxSeparatePool);

    final String username = getStringIfSetOrGetDefault(dataSourceNode, USERNAME, null);
    final String password =
        getResolvedStringIfSetOrGetDefault(operationContext, dataSourceNode, PASSWORD, null);
    final String securityDomain = getStringIfSetOrGetDefault(dataSourceNode, SECURITY_DOMAIN, null);

    final Extension reauthPlugin =
        extractExtension(dataSourceNode, REAUTHPLUGIN_CLASSNAME, REAUTHPLUGIN_PROPERTIES);

    final DsSecurity security =
        new DsSecurityImpl(username, password, securityDomain, reauthPlugin);

    final Boolean sharePreparedStatements =
        dataSourceNode.hasDefined(SHAREPREPAREDSTATEMENTS.getName())
            ? dataSourceNode.get(SHAREPREPAREDSTATEMENTS.getName()).asBoolean()
            : Defaults.SHARE_PREPARED_STATEMENTS;
    final Long preparedStatementsCacheSize =
        getLongIfSetOrGetDefault(dataSourceNode, PREPAREDSTATEMENTSCACHESIZE, null);
    final Statement.TrackStatementsEnum trackStatements =
        dataSourceNode.hasDefined(TRACKSTATEMENTS.getName())
            ? Statement.TrackStatementsEnum.valueOf(
                dataSourceNode.get(TRACKSTATEMENTS.getName()).asString())
            : Defaults.TRACK_STATEMENTS;
    final Statement statement =
        new StatementImpl(sharePreparedStatements, preparedStatementsCacheSize, trackStatements);

    final Integer allocationRetry = getIntIfSetOrGetDefault(dataSourceNode, ALLOCATION_RETRY, null);
    final Long allocationRetryWaitMillis =
        getLongIfSetOrGetDefault(dataSourceNode, ALLOCATION_RETRY_WAIT_MILLIS, null);
    final Long blockingTimeoutMillis =
        getLongIfSetOrGetDefault(dataSourceNode, BLOCKING_TIMEOUT_WAIT_MILLIS, null);
    final Long idleTimeoutMinutes =
        getLongIfSetOrGetDefault(dataSourceNode, IDLETIMEOUTMINUTES, null);
    final Long queryTimeout = getLongIfSetOrGetDefault(dataSourceNode, QUERYTIMEOUT, null);
    final Integer xaResourceTimeout =
        getIntIfSetOrGetDefault(dataSourceNode, XA_RESOURCE_TIMEOUT, null);
    final Long useTryLock = getLongIfSetOrGetDefault(dataSourceNode, USETRYLOCK, null);
    final Boolean setTxQuertTimeout =
        getBooleanIfSetOrGetDefault(
            dataSourceNode, SETTXQUERYTIMEOUT, Defaults.SET_TX_QUERY_TIMEOUT);
    final TimeOut timeOut =
        new TimeOutImpl(
            blockingTimeoutMillis,
            idleTimeoutMinutes,
            allocationRetry,
            allocationRetryWaitMillis,
            xaResourceTimeout,
            setTxQuertTimeout,
            queryTimeout,
            useTryLock);
    final TransactionIsolation transactionIsolation =
        dataSourceNode.hasDefined(TRANSACTION_ISOLATION.getName())
            ? TransactionIsolation.valueOf(
                dataSourceNode.get(TRANSACTION_ISOLATION.getName()).asString())
            : null;
    final String checkValidConnectionSql =
        getStringIfSetOrGetDefault(dataSourceNode, CHECKVALIDCONNECTIONSQL, null);

    final Extension exceptionSorter =
        extractExtension(dataSourceNode, EXCEPTIONSORTERCLASSNAME, EXCEPTIONSORTER_PROPERTIES);
    final Extension staleConnectionChecker =
        extractExtension(
            dataSourceNode, STALECONNECTIONCHECKERCLASSNAME, STALECONNECTIONCHECKER_PROPERTIES);
    final Extension validConnectionChecker =
        extractExtension(
            dataSourceNode, VALIDCONNECTIONCHECKERCLASSNAME, VALIDCONNECTIONCHECKER_PROPERTIES);

    Long backgroundValidationMillis =
        getLongIfSetOrGetDefault(dataSourceNode, BACKGROUNDVALIDATIONMILLIS, null);
    final Boolean backgroundValidation =
        getBooleanIfSetOrGetDefault(
            dataSourceNode, BACKGROUNDVALIDATION, Defaults.BACKGROUND_VALIDATION);
    boolean useFastFail =
        getBooleanIfSetOrGetDefault(dataSourceNode, USE_FAST_FAIL, Defaults.USE_FAST_FAIl);
    final Boolean validateOnMatch =
        getBooleanIfSetOrGetDefault(dataSourceNode, VALIDATEONMATCH, Defaults.VALIDATE_ON_MATCH);
    final Boolean spy = getBooleanIfSetOrGetDefault(dataSourceNode, SPY, Defaults.SPY);
    final Boolean useCcm = getBooleanIfSetOrGetDefault(dataSourceNode, USE_CCM, Defaults.USE_CCM);
    final Validation validation =
        new ValidationImpl(
            backgroundValidation,
            backgroundValidationMillis,
            useFastFail,
            validConnectionChecker,
            checkValidConnectionSql,
            validateOnMatch,
            staleConnectionChecker,
            exceptionSorter);

    final String recoveryUsername =
        getStringIfSetOrGetDefault(dataSourceNode, RECOVERY_USERNAME, null);
    final String recoveryPassword =
        getResolvedStringIfSetOrGetDefault(
            operationContext, dataSourceNode, RECOVERY_PASSWORD, null);
    final String recoverySecurityDomain =
        getStringIfSetOrGetDefault(dataSourceNode, RECOVERY_SECURITY_DOMAIN, null);
    final Boolean noRecovery = getBooleanIfSetOrGetDefault(dataSourceNode, NO_RECOVERY, null);

    Recovery recovery = null;
    if (recoveryUsername != null
        || recoveryPassword != null
        || recoverySecurityDomain != null
        || (noRecovery != null && noRecovery.booleanValue())) {
      final Credential credential =
          new CredentialImpl(recoveryUsername, recoveryPassword, recoverySecurityDomain);
      final Extension recoverPlugin =
          extractExtension(dataSourceNode, RECOVERLUGIN_CLASSNAME, RECOVERLUGIN_PROPERTIES);

      recovery = new Recovery(credential, recoverPlugin, noRecovery);
    }
    return new ModifiableXaDataSource(
        transactionIsolation,
        timeOut,
        security,
        statement,
        validation,
        urlDelimiter,
        urlSelectorStrategyClassName,
        useJavaContext,
        poolName,
        enabled,
        jndiName,
        spy,
        useCcm,
        xaDataSourceProperty,
        xaDataSourceClass,
        module,
        newConnectionSql,
        xaPool,
        recovery);
  }
    private void writeConDef(
        XMLExtendedStreamWriter streamWriter,
        ModelNode conDef,
        final String poolName,
        final boolean isXa)
        throws XMLStreamException {
      streamWriter.writeStartElement(ResourceAdapter.Tag.CONNECTION_DEFINITION.getLocalName());
      CLASS_NAME.marshallAsAttribute(conDef, streamWriter);
      JNDINAME.marshallAsAttribute(conDef, streamWriter);
      ENABLED.marshallAsAttribute(conDef, streamWriter);
      USE_JAVA_CONTEXT.marshallAsAttribute(conDef, streamWriter);
      streamWriter.writeAttribute("pool-name", poolName);
      USE_CCM.marshallAsAttribute(conDef, streamWriter);

      writeNewConfigProperties(streamWriter, conDef);

      if (conDef.hasDefined(MAX_POOL_SIZE.getName())
          || conDef.hasDefined(MIN_POOL_SIZE.getName())
          || conDef.hasDefined(POOL_USE_STRICT_MIN.getName())
          || conDef.hasDefined(POOL_PREFILL.getName())
          || conDef.hasDefined(POOL_FLUSH_STRATEGY.getName())) {
        if (isXa) {

          streamWriter.writeStartElement(CommonConnDef.Tag.XA_POOL.getLocalName());
          MIN_POOL_SIZE.marshallAsElement(conDef, streamWriter);
          MAX_POOL_SIZE.marshallAsElement(conDef, streamWriter);
          POOL_PREFILL.marshallAsElement(conDef, streamWriter);
          POOL_USE_STRICT_MIN.marshallAsElement(conDef, streamWriter);
          POOL_FLUSH_STRATEGY.marshallAsElement(conDef, streamWriter);

          SAME_RM_OVERRIDE.marshallAsElement(conDef, streamWriter);
          INTERLEAVING.marshallAsElement(conDef, streamWriter);
          NOTXSEPARATEPOOL.marshallAsElement(conDef, streamWriter);
          PAD_XID.marshallAsElement(conDef, streamWriter);
          WRAP_XA_RESOURCE.marshallAsElement(conDef, streamWriter);

          streamWriter.writeEndElement();
        } else {
          streamWriter.writeStartElement(CommonConnDef.Tag.POOL.getLocalName());
          MIN_POOL_SIZE.marshallAsElement(conDef, streamWriter);
          MAX_POOL_SIZE.marshallAsElement(conDef, streamWriter);
          POOL_PREFILL.marshallAsElement(conDef, streamWriter);
          POOL_USE_STRICT_MIN.marshallAsElement(conDef, streamWriter);
          POOL_FLUSH_STRATEGY.marshallAsElement(conDef, streamWriter);
          streamWriter.writeEndElement();
        }
      }

      if (conDef.hasDefined(APPLICATION.getName())
          || conDef.hasDefined(SECURITY_DOMAIN.getName())
          || conDef.hasDefined(SECURITY_DOMAIN_AND_APPLICATION.getName())) {
        streamWriter.writeStartElement(CommonConnDef.Tag.SECURITY.getLocalName());
        APPLICATION.marshallAsElement(conDef, streamWriter);
        SECURITY_DOMAIN.marshallAsElement(conDef, streamWriter);
        SECURITY_DOMAIN_AND_APPLICATION.marshallAsElement(conDef, streamWriter);

        streamWriter.writeEndElement();
      }

      if (conDef.hasDefined(BLOCKING_TIMEOUT_WAIT_MILLIS.getName())
          || conDef.hasDefined(IDLETIMEOUTMINUTES.getName())
          || conDef.hasDefined(ALLOCATION_RETRY.getName())
          || conDef.hasDefined(ALLOCATION_RETRY_WAIT_MILLIS.getName())
          || conDef.hasDefined(XA_RESOURCE_TIMEOUT.getName())) {
        streamWriter.writeStartElement(CommonConnDef.Tag.TIMEOUT.getLocalName());
        BLOCKING_TIMEOUT_WAIT_MILLIS.marshallAsElement(conDef, streamWriter);
        IDLETIMEOUTMINUTES.marshallAsElement(conDef, streamWriter);
        ALLOCATION_RETRY.marshallAsElement(conDef, streamWriter);
        ALLOCATION_RETRY_WAIT_MILLIS.marshallAsElement(conDef, streamWriter);
        XA_RESOURCE_TIMEOUT.marshallAsElement(conDef, streamWriter);
        streamWriter.writeEndElement();
      }

      if (conDef.hasDefined(BACKGROUNDVALIDATION.getName())
          || conDef.hasDefined(BACKGROUNDVALIDATIONMILLIS.getName())
          || conDef.hasDefined(USE_FAST_FAIL.getName())) {
        streamWriter.writeStartElement(CommonConnDef.Tag.VALIDATION.getLocalName());
        BACKGROUNDVALIDATION.marshallAsElement(conDef, streamWriter);
        BACKGROUNDVALIDATIONMILLIS.marshallAsElement(conDef, streamWriter);
        USE_FAST_FAIL.marshallAsElement(conDef, streamWriter);
        streamWriter.writeEndElement();
      }

      if (conDef.hasDefined(RECOVERY_USERNAME.getName())
          || conDef.hasDefined(RECOVERY_PASSWORD.getName())
          || conDef.hasDefined(RECOVERY_SECURITY_DOMAIN.getName())
          || conDef.hasDefined(RECOVERLUGIN_CLASSNAME.getName())
          || conDef.hasDefined(RECOVERLUGIN_PROPERTIES.getName())
          || conDef.hasDefined(NO_RECOVERY.getName())) {

        streamWriter.writeStartElement(CommonConnDef.Tag.RECOVERY.getLocalName());
        if (conDef.hasDefined(RECOVERY_USERNAME.getName())
            || conDef.hasDefined(RECOVERY_PASSWORD.getName())
            || conDef.hasDefined(RECOVERY_SECURITY_DOMAIN.getName())) {
          streamWriter.writeStartElement(Recovery.Tag.RECOVER_CREDENTIAL.getLocalName());
          RECOVERY_USERNAME.marshallAsElement(conDef, streamWriter);
          RECOVERY_PASSWORD.marshallAsElement(conDef, streamWriter);
          RECOVERY_SECURITY_DOMAIN.marshallAsElement(conDef, streamWriter);
          streamWriter.writeEndElement();
        }
        if (conDef.hasDefined(RECOVERLUGIN_CLASSNAME.getName())
            || conDef.hasDefined(RECOVERLUGIN_PROPERTIES.getName())) {
          streamWriter.writeStartElement(Recovery.Tag.RECOVER_PLUGIN.getLocalName());
          RECOVERLUGIN_CLASSNAME.marshallAsAttribute(conDef, streamWriter);
          if (conDef.hasDefined(RECOVERLUGIN_PROPERTIES.getName())) {
            for (Property property :
                conDef.get(RECOVERLUGIN_PROPERTIES.getName()).asPropertyList()) {
              writeProperty(
                  streamWriter,
                  conDef,
                  property.getName(),
                  property.getValue().asString(),
                  org.jboss.jca.common.api.metadata.common.Extension.Tag.CONFIG_PROPERTY
                      .getLocalName());
            }
          }
          streamWriter.writeEndElement();
        }
        NO_RECOVERY.marshallAsAttribute(conDef, streamWriter);
      }

      streamWriter.writeEndElement();
    }
  static ModifiableDataSource from(
      final OperationContext operationContext, final ModelNode dataSourceNode, final String dsName)
      throws OperationFailedException, ValidateException {
    final Map<String, String> connectionProperties = Collections.emptyMap();

    final String connectionUrl = getStringIfSetOrGetDefault(dataSourceNode, CONNECTION_URL, null);
    final String driverClass = getStringIfSetOrGetDefault(dataSourceNode, DRIVER_CLASS, null);
    final String dataSourceClass =
        getStringIfSetOrGetDefault(dataSourceNode, DATASOURCE_CLASS, null);
    final String jndiName = getStringIfSetOrGetDefault(dataSourceNode, JNDINAME, null);
    final String driver = getStringIfSetOrGetDefault(dataSourceNode, DATASOURCE_DRIVER, null);
    final String newConnectionSql =
        getStringIfSetOrGetDefault(dataSourceNode, NEW_CONNECTION_SQL, null);
    final String poolName = dsName;
    final String urlDelimiter = getStringIfSetOrGetDefault(dataSourceNode, URL_DELIMITER, null);
    final String urlSelectorStrategyClassName =
        getStringIfSetOrGetDefault(dataSourceNode, URL_SELECTOR_STRATEGY_CLASS_NAME, null);
    final boolean useJavaContext =
        getBooleanIfSetOrGetDefault(dataSourceNode, USE_JAVA_CONTEXT, Defaults.USE_JAVA_CONTEXT);
    final boolean enabled = getBooleanIfSetOrGetDefault(dataSourceNode, ENABLED, Defaults.ENABLED);
    final boolean jta = getBooleanIfSetOrGetDefault(dataSourceNode, JTA, Defaults.JTA);
    final Integer maxPoolSize =
        getIntIfSetOrGetDefault(dataSourceNode, MAX_POOL_SIZE, Defaults.MAX_POOL_SIZE);
    final Integer minPoolSize =
        getIntIfSetOrGetDefault(dataSourceNode, MIN_POOL_SIZE, Defaults.MIN_POOL_SIZE);
    final boolean prefill =
        getBooleanIfSetOrGetDefault(dataSourceNode, POOL_PREFILL, Defaults.PREFILL);
    final boolean useStrictMin =
        getBooleanIfSetOrGetDefault(dataSourceNode, POOL_USE_STRICT_MIN, Defaults.USE_STRICT_MIN);
    final FlushStrategy flushStrategy =
        dataSourceNode.hasDefined(POOL_FLUSH_STRATEGY.getName())
            ? FlushStrategy.forName(dataSourceNode.get(POOL_FLUSH_STRATEGY.getName()).asString())
            : Defaults.FLUSH_STRATEGY;

    final CommonPool pool =
        new CommonPoolImpl(minPoolSize, maxPoolSize, prefill, useStrictMin, flushStrategy);

    final String username = getStringIfSetOrGetDefault(dataSourceNode, USERNAME, null);

    final String password =
        getResolvedStringIfSetOrGetDefault(operationContext, dataSourceNode, PASSWORD, null);
    final String securityDomain = getStringIfSetOrGetDefault(dataSourceNode, SECURITY_DOMAIN, null);

    final Extension reauthPlugin =
        extractExtension(dataSourceNode, REAUTHPLUGIN_CLASSNAME, REAUTHPLUGIN_PROPERTIES);

    final DsSecurity security =
        new DsSecurityImpl(username, password, securityDomain, reauthPlugin);

    final boolean sharePreparedStatements =
        getBooleanIfSetOrGetDefault(
            dataSourceNode, SHAREPREPAREDSTATEMENTS, Defaults.SHARE_PREPARED_STATEMENTS);
    final Long preparedStatementsCacheSize =
        getLongIfSetOrGetDefault(dataSourceNode, PREPAREDSTATEMENTSCACHESIZE, null);
    final Statement.TrackStatementsEnum trackStatements =
        dataSourceNode.hasDefined(TRACKSTATEMENTS.getName())
            ? Statement.TrackStatementsEnum.valueOf(
                dataSourceNode.get(TRACKSTATEMENTS.getName()).asString())
            : Defaults.TRACK_STATEMENTS;
    final Statement statement =
        new StatementImpl(sharePreparedStatements, preparedStatementsCacheSize, trackStatements);

    final Integer allocationRetry = getIntIfSetOrGetDefault(dataSourceNode, ALLOCATION_RETRY, null);
    final Long allocationRetryWaitMillis =
        getLongIfSetOrGetDefault(dataSourceNode, ALLOCATION_RETRY_WAIT_MILLIS, null);
    final Long blockingTimeoutMillis =
        getLongIfSetOrGetDefault(dataSourceNode, BLOCKING_TIMEOUT_WAIT_MILLIS, null);
    final Long idleTimeoutMinutes =
        getLongIfSetOrGetDefault(dataSourceNode, IDLETIMEOUTMINUTES, null);
    final Long queryTimeout = getLongIfSetOrGetDefault(dataSourceNode, QUERYTIMEOUT, null);
    final Integer xaResourceTimeout =
        getIntIfSetOrGetDefault(dataSourceNode, XA_RESOURCE_TIMEOUT, null);
    final Long useTryLock = getLongIfSetOrGetDefault(dataSourceNode, USETRYLOCK, null);
    final boolean setTxQuertTimeout =
        getBooleanIfSetOrGetDefault(
            dataSourceNode, SETTXQUERYTIMEOUT, Defaults.SET_TX_QUERY_TIMEOUT);
    final TimeOut timeOut =
        new TimeOutImpl(
            blockingTimeoutMillis,
            idleTimeoutMinutes,
            allocationRetry,
            allocationRetryWaitMillis,
            xaResourceTimeout,
            setTxQuertTimeout,
            queryTimeout,
            useTryLock);
    final TransactionIsolation transactionIsolation =
        dataSourceNode.hasDefined(TRANSACTION_ISOLATION.getName())
            ? TransactionIsolation.valueOf(
                dataSourceNode.get(TRANSACTION_ISOLATION.getName()).asString())
            : null;
    final String checkValidConnectionSql =
        getStringIfSetOrGetDefault(dataSourceNode, CHECKVALIDCONNECTIONSQL, null);

    final Extension exceptionSorter =
        extractExtension(dataSourceNode, EXCEPTIONSORTERCLASSNAME, EXCEPTIONSORTER_PROPERTIES);
    final Extension staleConnectionChecker =
        extractExtension(
            dataSourceNode, STALECONNECTIONCHECKERCLASSNAME, STALECONNECTIONCHECKER_PROPERTIES);
    final Extension validConnectionChecker =
        extractExtension(
            dataSourceNode, VALIDCONNECTIONCHECKERCLASSNAME, VALIDCONNECTIONCHECKER_PROPERTIES);

    Long backgroundValidationMillis =
        getLongIfSetOrGetDefault(dataSourceNode, BACKGROUNDVALIDATIONMILLIS, null);
    final boolean backgroundValidation =
        getBooleanIfSetOrGetDefault(
            dataSourceNode, BACKGROUNDVALIDATION, Defaults.BACKGROUND_VALIDATION);
    boolean useFastFail =
        getBooleanIfSetOrGetDefault(dataSourceNode, USE_FAST_FAIL, Defaults.USE_FAST_FAIl);
    final boolean validateOnMatch =
        getBooleanIfSetOrGetDefault(dataSourceNode, VALIDATEONMATCH, Defaults.VALIDATE_ON_MATCH);
    final boolean spy = getBooleanIfSetOrGetDefault(dataSourceNode, SPY, Defaults.SPY);
    final boolean useCcm = getBooleanIfSetOrGetDefault(dataSourceNode, USE_CCM, Defaults.USE_CCM);

    final Validation validation =
        new ValidationImpl(
            backgroundValidation,
            backgroundValidationMillis,
            useFastFail,
            validConnectionChecker,
            checkValidConnectionSql,
            validateOnMatch,
            staleConnectionChecker,
            exceptionSorter);

    return new ModifiableDataSource(
        connectionUrl,
        driverClass,
        dataSourceClass,
        driver,
        transactionIsolation,
        connectionProperties,
        timeOut,
        security,
        statement,
        validation,
        urlDelimiter,
        urlSelectorStrategyClassName,
        newConnectionSql,
        useJavaContext,
        poolName,
        enabled,
        jndiName,
        spy,
        useCcm,
        jta,
        pool);
  }