コード例 #1
0
  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);
  }
コード例 #2
0
  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);
  }