当前位置: 首页>>代码示例>>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;未经允许,请勿转载。