private void setMcfProperties(
        final BaseWrapperManagedConnectionFactory managedConnectionFactory,
        CommonDataSource dataSourceConfig,
        final Statement statement) {

      if (dataSourceConfig.getTransactionIsolation() != null) {
        managedConnectionFactory.setTransactionIsolation(
            dataSourceConfig.getTransactionIsolation().name());
      }

      final DsSecurity security = dataSourceConfig.getSecurity();
      if (security != null) {
        if (security.getUserName() != null) {
          managedConnectionFactory.setUserName(security.getUserName());
        }
        if (security.getPassword() != null) {
          managedConnectionFactory.setPassword(security.getPassword());
        }
      }

      final TimeOut timeOut = dataSourceConfig.getTimeOut();
      if (timeOut != null) {
        if (timeOut.getUseTryLock() != null) {
          managedConnectionFactory.setUseTryLock(timeOut.getUseTryLock().intValue());
        }
        if (timeOut.getQueryTimeout() != null) {
          managedConnectionFactory.setQueryTimeout(timeOut.getQueryTimeout().intValue());
        }
        if (timeOut.isSetTxQueryTimeout()) {
          managedConnectionFactory.setTransactionQueryTimeout(true);
        }
      }

      if (statement != null) {
        if (statement.getTrackStatements() != null) {
          managedConnectionFactory.setTrackStatements(statement.getTrackStatements().name());
        }
        if (statement.isSharePreparedStatements() != null) {
          managedConnectionFactory.setSharePreparedStatements(
              statement.isSharePreparedStatements());
        }
        if (statement.getPreparedStatementsCacheSize() != null) {
          managedConnectionFactory.setPreparedStatementCacheSize(
              statement.getPreparedStatementsCacheSize().intValue());
        }
      }

      final Validation validation = dataSourceConfig.getValidation();
      if (validation != null) {
        if (validation.getCheckValidConnectionSql() != null) {
          managedConnectionFactory.setCheckValidConnectionSQL(
              validation.getCheckValidConnectionSql());
        }
        final Extension validConnectionChecker = validation.getValidConnectionChecker();
        if (validConnectionChecker != null) {
          if (validConnectionChecker.getClassName() != null) {
            managedConnectionFactory.setValidConnectionCheckerClassName(
                validConnectionChecker.getClassName());
          }
          if (validConnectionChecker.getConfigPropertiesMap() != null) {
            managedConnectionFactory.setValidConnectionCheckerProperties(
                buildConfigPropsString(validConnectionChecker.getConfigPropertiesMap()));
          }
        }
        final Extension exceptionSorter = validation.getExceptionSorter();
        if (exceptionSorter != null) {
          if (exceptionSorter.getClassName() != null) {
            managedConnectionFactory.setExceptionSorterClassName(exceptionSorter.getClassName());
          }
          if (exceptionSorter.getConfigPropertiesMap() != null) {
            managedConnectionFactory.setExceptionSorterProperties(
                buildConfigPropsString(exceptionSorter.getConfigPropertiesMap()));
          }
        }
        final Extension staleConnectionChecker = validation.getStaleConnectionChecker();
        if (staleConnectionChecker != null) {
          if (staleConnectionChecker.getClassName() != null) {
            managedConnectionFactory.setStaleConnectionCheckerClassName(
                staleConnectionChecker.getClassName());
          }
          if (staleConnectionChecker.getConfigPropertiesMap() != null) {
            managedConnectionFactory.setStaleConnectionCheckerProperties(
                buildConfigPropsString(staleConnectionChecker.getConfigPropertiesMap()));
          }
        }
      }
    }
Ejemplo n.º 2
0
  private void writeValidation(XMLExtendedStreamWriter streamWriter, Validation validation)
      throws XMLStreamException {
    if (validation != null) {
      if (validation.getValidConnectionCheckerClassName() != null) {
        streamWriter.writeStartElement(
            Validation.Tag.VALIDCONNECTIONCHECKERCLASSNAME.getLocalName());
        streamWriter.writeCharacters(validation.getValidConnectionCheckerClassName());
        streamWriter.writeEndElement();
      }

      if (validation.getCheckValidConnectionSql() != null) {
        streamWriter.writeStartElement(Validation.Tag.CHECKVALIDCONNECTIONSQL.getLocalName());
        streamWriter.writeCharacters(validation.getCheckValidConnectionSql());
        streamWriter.writeEndElement();
      }

      if (validation.isValidateOnMatch() != null) {
        streamWriter.writeStartElement(Validation.Tag.VALIDATEONMATCH.getLocalName());
        streamWriter.writeCharacters(validation.isValidateOnMatch().toString());
        streamWriter.writeEndElement();
      }

      if (validation.isBackgroundValidation() != null) {
        streamWriter.writeStartElement(Validation.Tag.BACKGROUNDVALIDATION.getLocalName());
        streamWriter.writeCharacters(validation.isBackgroundValidation().toString());
        streamWriter.writeEndElement();
      }

      if (validation.getBackgroundValidationMinutes() != null) {
        streamWriter.writeStartElement(Validation.Tag.BACKGROUNDVALIDATIONMINUTES.getLocalName());
        streamWriter.writeCharacters(validation.getBackgroundValidationMinutes().toString());
        streamWriter.writeEndElement();
      }

      if (validation.isUseFastFail() != null) {
        streamWriter.writeStartElement(Validation.Tag.USEFASTFAIL.getLocalName());
        streamWriter.writeCharacters(validation.isUseFastFail().toString());
        streamWriter.writeEndElement();
      }

      if (validation.getStaleConnectionCheckerClassName() != null) {
        streamWriter.writeStartElement(
            Validation.Tag.STALECONNECTIONCHECKERCLASSNAME.getLocalName());
        streamWriter.writeCharacters(validation.getStaleConnectionCheckerClassName());
        streamWriter.writeEndElement();
      }

      if (validation.getExceptionSorterClassName() != null) {
        streamWriter.writeStartElement(Validation.Tag.EXCEPTIONSORTERCLASSNAME.getLocalName());
        streamWriter.writeCharacters(validation.getExceptionSorterClassName().toString());
        streamWriter.writeEndElement();
      }
    }
  }