relaxed @AspectJ detection check (for CGLIB subclasses to still be recognized as an aspect)
This commit is contained in:
parent
56a48272e6
commit
3e63951a57
|
|
@ -112,12 +112,11 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||||
* when compiled by ajc with the -1.5 flag, yet they cannot be consumed by Spring AOP.
|
* when compiled by ajc with the -1.5 flag, yet they cannot be consumed by Spring AOP.
|
||||||
*/
|
*/
|
||||||
public boolean isAspect(Class<?> clazz) {
|
public boolean isAspect(Class<?> clazz) {
|
||||||
return (AjTypeSystem.getAjType(clazz).isAspect() &&
|
return (hasAspectAnnotation(clazz) && !compiledByAjc(clazz));
|
||||||
hasAspectAnnotation(clazz) && !compiledByAjc(clazz));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasAspectAnnotation(Class<?> clazz) {
|
private boolean hasAspectAnnotation(Class<?> clazz) {
|
||||||
return clazz.isAnnotationPresent(Aspect.class);
|
return (AnnotationUtils.findAnnotation(clazz, Aspect.class) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2006 the original author or authors.
|
* Copyright 2002-2009 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -67,13 +67,23 @@ public class AspectMetadata {
|
||||||
* @param aspectClass the aspect class
|
* @param aspectClass the aspect class
|
||||||
* @param aspectName the name of the aspect
|
* @param aspectName the name of the aspect
|
||||||
*/
|
*/
|
||||||
public AspectMetadata(Class aspectClass, String aspectName) {
|
public AspectMetadata(Class<?> aspectClass, String aspectName) {
|
||||||
this.aspectName = aspectName;
|
this.aspectName = aspectName;
|
||||||
this.ajType = AjTypeSystem.getAjType(aspectClass);
|
|
||||||
|
|
||||||
if (!this.ajType.isAspect()) {
|
Class<?> currClass = aspectClass;
|
||||||
|
AjType ajType = null;
|
||||||
|
while (!currClass.equals(Object.class)) {
|
||||||
|
AjType ajTypeToCheck = AjTypeSystem.getAjType(currClass);
|
||||||
|
if (ajTypeToCheck.isAspect()) {
|
||||||
|
ajType = ajTypeToCheck;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
currClass = currClass.getSuperclass();
|
||||||
|
}
|
||||||
|
if (ajType == null) {
|
||||||
throw new IllegalArgumentException("Class '" + aspectClass.getName() + "' is not an @AspectJ aspect");
|
throw new IllegalArgumentException("Class '" + aspectClass.getName() + "' is not an @AspectJ aspect");
|
||||||
}
|
}
|
||||||
|
this.ajType = ajType;
|
||||||
if (this.ajType.getDeclarePrecedence().length > 0) {
|
if (this.ajType.getDeclarePrecedence().length > 0) {
|
||||||
throw new IllegalArgumentException("DeclarePrecendence not presently supported in Spring AOP");
|
throw new IllegalArgumentException("DeclarePrecendence not presently supported in Spring AOP");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue