org.springframework.transaction.annotation.AnnotationTransactionAttributeSource Java Examples

The following examples show how to use org.springframework.transaction.annotation.AnnotationTransactionAttributeSource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransactionAspectTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #2
Source File: TransactionConfigDefinitionValidator.java    From ByteTCC with GNU Lesser General Public License v3.0 5 votes vote down vote up
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));
			} // end-if (errorExists)
		}

	} // end-for (int i = 0; i < beanNameArray.length; i++)
}
 
Example #3
Source File: SampleTransactionManagementConfiguration.java    From spring-boot-graal-feature with Apache License 2.0 4 votes vote down vote up
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public TransactionAttributeSource transactionAttributeSource() {
	return new AnnotationTransactionAttributeSource();
}
 
Example #4
Source File: SampleTransactionManagementConfiguration.java    From spring-boot-graal-feature with Apache License 2.0 4 votes vote down vote up
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public TransactionAttributeSource transactionAttributeSource() {
	return new AnnotationTransactionAttributeSource();
}
 
Example #5
Source File: SampleTransactionManagementConfiguration.java    From spring-boot-graal-feature with Apache License 2.0 4 votes vote down vote up
@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public TransactionAttributeSource transactionAttributeSource() {
	return new AnnotationTransactionAttributeSource();
}
 
Example #6
Source File: DomainTransactionInterceptor.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Override
public TransactionAttributeSource getTransactionAttributeSource() {
    return new AnnotationTransactionAttributeSource(new DomainTransactionAnnotationParser());
}
 
Example #7
Source File: AnnotationAndNameMatchingTransactionAttributeSource.java    From rice with Educational Community License v2.0 2 votes vote down vote up
/**
 * Sets the annotationTransactionAttributeSource attribute value.
 *
 * @param annotationTransactionAttributeSource The annotationTransactionAttributeSource to set.
 */
public void setAnnotationTransactionAttributeSource(AnnotationTransactionAttributeSource annotationTransactionAttributeSource) {
    this.annotationTransactionAttributeSource = annotationTransactionAttributeSource;
}