LoadTimeWeavingConfiguration should not rely on private field injection
Issue: SPR-12776
This commit is contained in:
parent
590b23ccb3
commit
1259671f3f
|
@ -26,9 +26,6 @@ import org.springframework.context.weaving.DefaultContextLoadTimeWeaver;
|
|||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.instrument.classloading.LoadTimeWeaver;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import static org.springframework.context.weaving.AspectJWeavingEnabler.*;
|
||||
|
||||
/**
|
||||
* {@code @Configuration} class that registers a {@link LoadTimeWeaver} bean.
|
||||
|
@ -47,7 +44,6 @@ public class LoadTimeWeavingConfiguration implements ImportAware, BeanClassLoade
|
|||
|
||||
private AnnotationAttributes enableLTW;
|
||||
|
||||
@Autowired(required = false)
|
||||
private LoadTimeWeavingConfigurer ltwConfigurer;
|
||||
|
||||
private ClassLoader beanClassLoader;
|
||||
|
@ -56,9 +52,16 @@ public class LoadTimeWeavingConfiguration implements ImportAware, BeanClassLoade
|
|||
@Override
|
||||
public void setImportMetadata(AnnotationMetadata importMetadata) {
|
||||
this.enableLTW = AnnotationConfigUtils.attributesFor(importMetadata, EnableLoadTimeWeaving.class);
|
||||
Assert.notNull(this.enableLTW,
|
||||
if (this.enableLTW == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"@EnableLoadTimeWeaving is not present on importing class " + importMetadata.getClassName());
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired(required = false)
|
||||
public void setLoadTimeWeavingConfigurer(LoadTimeWeavingConfigurer ltwConfigurer) {
|
||||
this.ltwConfigurer = ltwConfigurer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader beanClassLoader) {
|
||||
|
@ -87,7 +90,7 @@ public class LoadTimeWeavingConfiguration implements ImportAware, BeanClassLoade
|
|||
// AJ weaving is disabled -> do nothing
|
||||
break;
|
||||
case AUTODETECT:
|
||||
if (this.beanClassLoader.getResource(ASPECTJ_AOP_XML_RESOURCE) == null) {
|
||||
if (this.beanClassLoader.getResource(AspectJWeavingEnabler.ASPECTJ_AOP_XML_RESOURCE) == null) {
|
||||
// No aop.xml present on the classpath -> treat as 'disabled'
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue