當前位置: 首頁>>代碼示例>>Java>>正文


Java TransactionConfiguration類代碼示例

本文整理匯總了Java中org.springframework.test.context.transaction.TransactionConfiguration的典型用法代碼示例。如果您正苦於以下問題:Java TransactionConfiguration類的具體用法?Java TransactionConfiguration怎麽用?Java TransactionConfiguration使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TransactionConfiguration類屬於org.springframework.test.context.transaction包,在下文中一共展示了TransactionConfiguration類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: retrieveTransactionConfigurationAttributes

import org.springframework.test.context.transaction.TransactionConfiguration; //導入依賴的package包/類
/**
 * <p>
 * Retrieves the {@link TransactionConfigurationAttributes} for the
 * specified {@link Class class} which may optionally declare or inherit a
 * {@link TransactionConfiguration @TransactionConfiguration}. If a
 * {@link TransactionConfiguration} annotation is not present for the
 * supplied class, the <entityManager>default values</entityManager> for attributes defined in
 * {@link TransactionConfiguration} will be used instead.
 * @param clazz the Class object corresponding to the test class for which
 * the configuration attributes should be retrieved
 * @return a new TransactionConfigurationAttributes instance
 */
private TransactionConfigurationAttributes retrieveTransactionConfigurationAttributes(Class<?> clazz) {
    Class<TransactionConfiguration> annotationType = TransactionConfiguration.class;
    TransactionConfiguration config = clazz.getAnnotation(annotationType);
    if (logger.isDebugEnabled()) {
        logger.debug("Retrieved @TransactionConfiguration [" + config + "] for test class [" + clazz + "]");
    }

    String transactionManagerName;
    boolean defaultRollback;
    if (config != null) {
        transactionManagerName = config.transactionManager();
        defaultRollback = config.defaultRollback();
    }
    else {
        transactionManagerName = (String) AnnotationUtils.getDefaultValue(annotationType, "transactionManager");
        defaultRollback = (Boolean) AnnotationUtils.getDefaultValue(annotationType, "defaultRollback");
    }

    TransactionConfigurationAttributes configAttributes =
            new TransactionConfigurationAttributes(transactionManagerName, defaultRollback);
    if (logger.isDebugEnabled()) {
        logger.debug("Retrieved TransactionConfigurationAttributes [" + configAttributes + "] for class [" + clazz + "]");
    }
    return configAttributes;
}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:38,代碼來源:MergeTransactionalTestExecutionListener.java

示例2: retrieveConfigurationAttributes

import org.springframework.test.context.transaction.TransactionConfiguration; //導入依賴的package包/類
/**
 * Retrieves the {@link TransactionConfigurationAttributes} for the
 * specified {@link Class class} which may optionally declare or inherit a
 * {@link TransactionConfiguration &#064;TransactionConfiguration}. If a
 * {@link TransactionConfiguration} annotation is not present for the
 * supplied class, the <em>default values</em> for attributes defined in
 * {@link TransactionConfiguration} will be used instead.
 * 
 * @param clazz
 *            the Class object corresponding to the test class for which the
 *            configuration attributes should be retrieved
 * @return a new TransactionConfigurationAttributes instance
 */
private TransactionConfigurationAttributes retrieveConfigurationAttributes(
		TestContext testContext) {

	if (this.configurationAttributes == null) {
		Class<?> clazz = testContext.getTestClass();
		Class<TransactionConfiguration> annotationType = TransactionConfiguration.class;
		TransactionConfiguration config = clazz
				.getAnnotation(annotationType);
		if (logger.isDebugEnabled()) {
			logger.debug("Retrieved @TransactionConfiguration [" + config
					+ "] for test class [" + clazz + "]");
		}

		String transactionManagerName;
		boolean defaultRollback;
		if (config != null) {
			transactionManagerName = config.transactionManager();
			defaultRollback = config.defaultRollback();
		} else {
			transactionManagerName = (String) AnnotationUtils
					.getDefaultValue(annotationType, "transactionManager");
			defaultRollback = (Boolean) AnnotationUtils.getDefaultValue(
					annotationType, "defaultRollback");
		}

		TransactionConfigurationAttributes configAttributes = new TransactionConfigurationAttributes(
				transactionManagerName, defaultRollback);
		if (logger.isDebugEnabled()) {
			logger.debug("Retrieved TransactionConfigurationAttributes ["
					+ configAttributes + "] for class [" + clazz + "]");
		}
		this.configurationAttributes = configAttributes;
	}
	return this.configurationAttributes;
}
 
開發者ID:fpuna-cia,項目名稱:karaku,代碼行數:49,代碼來源:TransactionalTestCucumberExecutionListener.java


注:本文中的org.springframework.test.context.transaction.TransactionConfiguration類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。