Java 类org.springframework.transaction.annotation.AnnotationTransactionAttributeSource 实例源码

项目:joyrest    文件:OAuth2Initializer.java   
private DefaultTokenServices txProxiedTokenServices(DefaultTokenServices tokenServices, DataSource dataSource) {
    AnnotationTransactionAttributeSource attrSource = new AnnotationTransactionAttributeSource();
    DataSourceTransactionManager txManager = new DataSourceTransactionManager(dataSource);
    TransactionInterceptor txInterceptor = transactionInterceptor(attrSource, txManager);
    BeanFactoryTransactionAttributeSourceAdvisor txAdvisor = transactionAdvisor(attrSource, txInterceptor);
    ClassLoader classLoader = ClassUtils.getDefaultClassLoader();

    ProxyFactory proxyFactory = new ProxyFactory(tokenServices);
    proxyFactory.addAdvice(txInterceptor);
    proxyFactory.addAdvisor(txAdvisor);
    proxyFactory.setInterfaces(
        ClassUtils.getAllInterfacesForClass(
            new SingletonTargetSource(tokenServices).getTargetClass(), classLoader));

    return (DefaultTokenServices) proxyFactory.getProxy(classLoader);
}
项目:Equella    文件:TLETransactionInterceptor.java   
public TLETransactionInterceptor(AnnotationTransactionAttributeSource attributes,
    Provider<TLETransactionManager> managerProvider, String factoryName, boolean system)
{
    this.attributes = attributes;
    this.factoryName = factoryName;
    this.system = system;
    this.managerProvider = managerProvider;
}
项目:spring4-understanding    文件:TransactionAspectTests.java   
/**
 * Note: resolution does not occur. Thus we can't make a class transactional if
 * it implements a transactionally annotated interface. This behaviour could only
 * be changed in AbstractFallbackTransactionAttributeSource in Spring proper.
 */
public void testDoesNotResolveTxAnnotationOnMethodFromClassImplementingAnnotatedInterface() throws Exception {
    AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
    Method m = ImplementsAnnotatedInterface.class.getMethod("echo", Throwable.class);
    TransactionAttribute ta = atas.getTransactionAttribute(m, ImplementsAnnotatedInterface.class);
    assertNull(ta);
}
项目:ByteTCC    文件:TransactionConfigPostProcessor.java   
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    String[] beanNameArray = beanFactory.getBeanDefinitionNames();
    for (int i = 0; i < beanNameArray.length; i++) {
        String beanName = beanNameArray[i];
        BeanDefinition beanDef = beanFactory.getBeanDefinition(beanName);
        String beanClassName = beanDef.getBeanClassName();

        if (org.springframework.transaction.interceptor.TransactionProxyFactoryBean.class.getName().equals(beanClassName)) {
            throw new FatalBeanException(String.format(
                    "Declaring transactions by configuration is not supported yet, please use annotations to declare transactions(beanId= %s).",
                    beanName));
        }

        if (org.springframework.transaction.interceptor.TransactionInterceptor.class.getName().equals(beanClassName)) {
            boolean errorExists = true;

            MutablePropertyValues mpv = beanDef.getPropertyValues();
            PropertyValue pv = mpv.getPropertyValue("transactionAttributeSource");
            Object value = pv == null ? null : pv.getValue();
            if (value != null && RuntimeBeanReference.class.isInstance(value)) {
                RuntimeBeanReference reference = (RuntimeBeanReference) value;
                BeanDefinition refBeanDef = beanFactory.getBeanDefinition(reference.getBeanName());
                String refBeanClassName = refBeanDef.getBeanClassName();
                errorExists = AnnotationTransactionAttributeSource.class.getName().equals(refBeanClassName) == false;
            }

            if (errorExists) {
                throw new FatalBeanException(String.format(
                        "Declaring transactions by configuration is not supported yet, please use annotations to declare transactions(beanId= %s).",
                        beanName));
            }

        }
    }
}
项目:play-guice-mirage-java-example    文件:Global.java   
@Override
protected void configure() {
    // TransactionManager
    PlatformTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);

    // TransactionInterceptor
    TransactionInterceptor transactionInterceptor = new TransactionInterceptor(transactionManager, new AnnotationTransactionAttributeSource(false));

    bindInterceptor(Matchers.any(), Matchers.annotatedWith(Transactional.class), transactionInterceptor);

    bind(PlatformTransactionManager.class).toInstance(transactionManager);
}
项目:joyrest    文件:OAuth2Initializer.java   
private BeanFactoryTransactionAttributeSourceAdvisor transactionAdvisor(
    AnnotationTransactionAttributeSource source, TransactionInterceptor interceptor) {
    BeanFactoryTransactionAttributeSourceAdvisor advisor = new BeanFactoryTransactionAttributeSourceAdvisor();
    advisor.setTransactionAttributeSource(source);
    advisor.setAdvice(interceptor);
    return advisor;
}
项目:joyrest    文件:OAuth2Initializer.java   
private TransactionInterceptor transactionInterceptor(
    AnnotationTransactionAttributeSource source, PlatformTransactionManager txManager) {
    TransactionInterceptor interceptor = new TransactionInterceptor();
    interceptor.setTransactionAttributeSource(source);
    interceptor.setTransactionManager(txManager);
    return interceptor;
}
项目:dbflute-play-guice-java-example    文件:TransactionModule.java   
@Override
protected void configure() {
    // TransactionManager
    bind(PlatformTransactionManager.class).toProvider(getPlatformTransactionManagerType()).in(Singleton.class);

    // TransactionInterceptor
    final TransactionInterceptor transactionInterceptor = new TransactionInterceptorEx(getProvider(PlatformTransactionManager.class), new AnnotationTransactionAttributeSource(false));
    bindInterceptor(Matchers.any(), Matchers.annotatedWith(Transactional.class), transactionInterceptor);
}
项目:JMaNGOS    文件:RealmModule.java   
@Bean
public TransactionInterceptor transactionInterceptorRealm() {

    return new TransactionInterceptor(transactionManagerRealm(),
            new AnnotationTransactionAttributeSource());
}
项目:JMaNGOS    文件:WorldModule.java   
@Bean
public TransactionInterceptor transactionInterceptorWorld() {

    return new TransactionInterceptor(transactionManagerWorld(),
            new AnnotationTransactionAttributeSource());
}
项目:JMaNGOS    文件:AuthModule.java   
@Bean
public TransactionInterceptor transactionInterceptorAuth() {

    return new TransactionInterceptor(transactionManagerAuth(),
            new AnnotationTransactionAttributeSource());
}
项目:class-guard    文件:TransactionAspectTests.java   
/**
 * Note: resolution does not occur. Thus we can't make a class transactional if
 * it implements a transactionally annotated interface. This behaviour could only
 * be changed in AbstractFallbackTransactionAttributeSource in Spring proper.
 * @throws SecurityException
 * @throws NoSuchMethodException
 */
public void testDoesNotResolveTxAnnotationOnMethodFromClassImplementingAnnotatedInterface() throws SecurityException, NoSuchMethodException {
    AnnotationTransactionAttributeSource atas = new AnnotationTransactionAttributeSource();
    Method m = ImplementsAnnotatedInterface.class.getMethod("echo", Throwable.class);
    TransactionAttribute ta = atas.getTransactionAttribute(m, ImplementsAnnotatedInterface.class);
    assertNull(ta);
}
项目:kc-rice    文件:AnnotationAndNameMatchingTransactionAttributeSource.java   
/**
 * Sets the annotationTransactionAttributeSource attribute value.
 *
 * @param annotationTransactionAttributeSource The annotationTransactionAttributeSource to set.
 */
public void setAnnotationTransactionAttributeSource(AnnotationTransactionAttributeSource annotationTransactionAttributeSource) {
    this.annotationTransactionAttributeSource = annotationTransactionAttributeSource;
}
项目:rice    文件:AnnotationAndNameMatchingTransactionAttributeSource.java   
/**
 * Sets the annotationTransactionAttributeSource attribute value.
 *
 * @param annotationTransactionAttributeSource The annotationTransactionAttributeSource to set.
 */
public void setAnnotationTransactionAttributeSource(AnnotationTransactionAttributeSource annotationTransactionAttributeSource) {
    this.annotationTransactionAttributeSource = annotationTransactionAttributeSource;
}
项目:kuali_rice    文件:AnnotationAndNameMatchingTransactionAttributeSource.java   
/**
 * Sets the annotationTransactionAttributeSource attribute value.
 *
 * @param annotationTransactionAttributeSource The annotationTransactionAttributeSource to set.
 */
public void setAnnotationTransactionAttributeSource(AnnotationTransactionAttributeSource annotationTransactionAttributeSource) {
    this.annotationTransactionAttributeSource = annotationTransactionAttributeSource;
}