Polishing around @EnableTransactionManagement

Issue: SPR-10864
This commit is contained in:
Juergen Hoeller
2013-12-02 11:00:26 +01:00
parent e8dead247c
commit ce917d5cbb
5 changed files with 13 additions and 15 deletions

View File

@@ -60,7 +60,7 @@ public abstract class AdviceModeImportSelector<A extends Annotation> implements
*/
@Override
public final String[] selectImports(AnnotationMetadata importingClassMetadata) {
Class<?> annoType = GenericTypeResolver.resolveTypeArgument(this.getClass(), AdviceModeImportSelector.class);
Class<?> annoType = GenericTypeResolver.resolveTypeArgument(getClass(), AdviceModeImportSelector.class);
AnnotationAttributes attributes = AnnotationConfigUtils.attributesFor(importingClassMetadata, annoType);
Assert.notNull(attributes, String.format(
"@%s is not present on importing class '%s' as expected",

View File

@@ -1,4 +1,4 @@
/*
/*
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,6 +20,7 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.config.AopConfigUtils;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.core.annotation.AnnotationAttributes;
@@ -31,8 +32,8 @@ import org.springframework.core.type.AnnotationMetadata;
* {@code proxyTargetClass} attributes set to the correct values.
*
* @author Chris Beams
* @see EnableAspectJAutoProxy
* @since 3.1
* @see EnableAspectJAutoProxy
*/
public class AutoProxyRegistrar implements ImportBeanDefinitionRegistrar {
@@ -45,7 +46,6 @@ public class AutoProxyRegistrar implements ImportBeanDefinitionRegistrar {
* attributes. If {@code mode} is set to {@code PROXY}, the APC is registered; if
* {@code proxyTargetClass} is set to {@code true}, then the APC is forced to use
* subclass (CGLIB) proxying.
*
* <p>Several {@code @Enable*} annotations expose both {@code mode} and
* {@code proxyTargetClass} attributes. It is important to note that most of these
* capabilities end up sharing a {@linkplain AopConfigUtils#AUTO_PROXY_CREATOR_BEAN_NAME
@@ -62,13 +62,12 @@ public class AutoProxyRegistrar implements ImportBeanDefinitionRegistrar {
AnnotationAttributes candidate = AnnotationConfigUtils.attributesFor(importingClassMetadata, annoType);
Object mode = candidate.get("mode");
Object proxyTargetClass = candidate.get("proxyTargetClass");
if (mode != null && proxyTargetClass != null
&& mode.getClass().equals(AdviceMode.class)
&& proxyTargetClass.getClass().equals(Boolean.class)) {
if (mode != null && proxyTargetClass != null && mode.getClass().equals(AdviceMode.class) &&
proxyTargetClass.getClass().equals(Boolean.class)) {
candidateFound = true;
if (mode == AdviceMode.PROXY) {
AopConfigUtils.registerAutoProxyCreatorIfNecessary(registry);
if ((Boolean)proxyTargetClass) {
if ((Boolean) proxyTargetClass) {
AopConfigUtils.forceAutoProxyCreatorToUseClassProxying(registry);
return;
}
@@ -87,4 +86,5 @@ public class AutoProxyRegistrar implements ImportBeanDefinitionRegistrar {
"altogether.", name, name, name));
}
}
}