当前位置: 首页>>代码示例>>Java>>正文


Java TransactionAttributeSource类代码示例

本文整理汇总了Java中org.springframework.transaction.interceptor.TransactionAttributeSource的典型用法代码示例。如果您正苦于以下问题:Java TransactionAttributeSource类的具体用法?Java TransactionAttributeSource怎么用?Java TransactionAttributeSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TransactionAttributeSource类属于org.springframework.transaction.interceptor包,在下文中一共展示了TransactionAttributeSource类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTransactionAttributeSource

import org.springframework.transaction.interceptor.TransactionAttributeSource; //导入依赖的package包/类
@Override
public TransactionAttributeSource getTransactionAttributeSource() {
    final TransactionAttributeSource origTxAttrSource = super.getTransactionAttributeSource();

    return new TransactionAttributeSource() {

        @Override
        public TransactionAttribute getTransactionAttribute(final Method method, final Class<?> targetClass) {
            TransactionAttribute txAttr = origTxAttrSource.getTransactionAttribute(method, targetClass);

            if (txAttr instanceof DefaultTransactionAttribute) {
                ((DefaultTransactionAttribute) txAttr).setQualifier(AuthContextUtils.getDomain());
            }

            return txAttr;
        }
    };
}
 
开发者ID:ilgrosso,项目名称:DynamicSpringTransactional,代码行数:19,代码来源:DynamicTransactionInterceptor.java

示例2: setTxAdvice

import org.springframework.transaction.interceptor.TransactionAttributeSource; //导入依赖的package包/类
/**
 * 读取事务管理中的策略
 * 
 * @param txAdvice
 * @throws Exception
 */
@SuppressWarnings("unchecked")
public void setTxAdvice(TransactionInterceptor txAdvice) throws Exception {
    if (txAdvice == null) {
        // 没有配置事务管理策略
        return;
    }
    // 从txAdvice获取到策略配置信息
    TransactionAttributeSource transactionAttributeSource = txAdvice.getTransactionAttributeSource();
    if (!(transactionAttributeSource instanceof NameMatchTransactionAttributeSource)) {
        return;
    }
    // 使用反射技术获取到NameMatchTransactionAttributeSource对象中的nameMap属性值
    NameMatchTransactionAttributeSource matchTransactionAttributeSource = (NameMatchTransactionAttributeSource) transactionAttributeSource;
    Field nameMapField = ReflectionUtils.findField(NameMatchTransactionAttributeSource.class, "nameMap");
    nameMapField.setAccessible(true); // 设置该字段可访问
    // 获取nameMap的值
    Map<String, TransactionAttribute> map = (Map<String, TransactionAttribute>) nameMapField.get(matchTransactionAttributeSource);
    
    // 遍历nameMap
    for (Map.Entry<String, TransactionAttribute> entry : map.entrySet()) {
        if (!entry.getValue().isReadOnly()) {// 判断之后定义了ReadOnly的策略才加入到slaveMethodPattern
            continue;
        }
        slaveMethodPattern.add(entry.getKey());
    }
}
 
开发者ID:6089555,项目名称:spring-boot-starter-dynamic-datasource,代码行数:33,代码来源:DataSourceAspect.java

示例3: rollbackRules

import org.springframework.transaction.interceptor.TransactionAttributeSource; //导入依赖的package包/类
@Test
public void rollbackRules() {
	TransactionInterceptor txInterceptor = (TransactionInterceptor) context.getBean("txRollbackAdvice");
	TransactionAttributeSource txAttrSource = txInterceptor.getTransactionAttributeSource();
	TransactionAttribute txAttr = txAttrSource.getTransactionAttribute(getAgeMethod,ITestBean.class);
	assertTrue("should be configured to rollback on Exception",txAttr.rollbackOn(new Exception()));

	txAttr = txAttrSource.getTransactionAttribute(setAgeMethod, ITestBean.class);
	assertFalse("should not rollback on RuntimeException",txAttr.rollbackOn(new RuntimeException()));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:TxNamespaceHandlerTests.java

示例4: testRollbackRules

import org.springframework.transaction.interceptor.TransactionAttributeSource; //导入依赖的package包/类
public void testRollbackRules() {
	TransactionInterceptor txInterceptor = (TransactionInterceptor) context.getBean("txRollbackAdvice");
	TransactionAttributeSource txAttrSource = txInterceptor.getTransactionAttributeSource();
	TransactionAttribute txAttr = txAttrSource.getTransactionAttribute(getAgeMethod,ITestBean.class);
	assertTrue("should be configured to rollback on Exception",txAttr.rollbackOn(new Exception()));

	txAttr = txAttrSource.getTransactionAttribute(setAgeMethod, ITestBean.class);
	assertFalse("should not rollback on RuntimeException",txAttr.rollbackOn(new RuntimeException()));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:10,代码来源:TxNamespaceHandlerTests.java

示例5: getTransactionAttributeSource

import org.springframework.transaction.interceptor.TransactionAttributeSource; //导入依赖的package包/类
@Override
public TransactionAttributeSource getTransactionAttributeSource() {
    final TransactionAttributeSource origTxAttrSource = super.getTransactionAttributeSource();

    return (final Method method, final Class<?> targetClass) -> {
        TransactionAttribute txAttr = origTxAttrSource.getTransactionAttribute(method, targetClass);

        if (txAttr instanceof DefaultTransactionAttribute) {
            ((DefaultTransactionAttribute) txAttr).setQualifier(AuthContextUtils.getDomain());
        }

        return txAttr;
    };
}
 
开发者ID:apache,项目名称:syncope,代码行数:15,代码来源:DomainTransactionInterceptor.java

示例6: getTransactionAttributeSource

import org.springframework.transaction.interceptor.TransactionAttributeSource; //导入依赖的package包/类
@Override
public TransactionAttributeSource getTransactionAttributeSource()
{
	return attributes;
}
 
开发者ID:equella,项目名称:Equella,代码行数:6,代码来源:TLETransactionInterceptor.java

示例7: transactionAttributeSource

import org.springframework.transaction.interceptor.TransactionAttributeSource; //导入依赖的package包/类
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public TransactionAttributeSource transactionAttributeSource() {
	return new AnnotationTransactionAttributeSource();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:ProxyTransactionManagementConfiguration.java

示例8: getTransactionAttributeSource

import org.springframework.transaction.interceptor.TransactionAttributeSource; //导入依赖的package包/类
public TransactionAttributeSource getTransactionAttributeSource() {
	return transactionAttributeSource;
}
 
开发者ID:gsgsdtc,项目名称:ldtm,代码行数:4,代码来源:TransactionInterceptor.java

示例9: setTransactionAttributeSource

import org.springframework.transaction.interceptor.TransactionAttributeSource; //导入依赖的package包/类
public void setTransactionAttributeSource(TransactionAttributeSource transactionAttributeSource) {
	this.transactionAttributeSource = transactionAttributeSource;
}
 
开发者ID:gsgsdtc,项目名称:ldtm,代码行数:4,代码来源:TransactionInterceptor.java

示例10: TransactionInterceptorEx

import org.springframework.transaction.interceptor.TransactionAttributeSource; //导入依赖的package包/类
protected TransactionInterceptorEx(Provider<PlatformTransactionManager> ptmp, TransactionAttributeSource tas) {
    setTransactionAttributeSource(tas);
    transactionManagerProvider = ptmp;
}
 
开发者ID:XenonAbe,项目名称:dbflute-play-guice-java-example,代码行数:5,代码来源:TransactionModule.java


注:本文中的org.springframework.transaction.interceptor.TransactionAttributeSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。