Browse Source

relaxed @AspectJ detection check (for CGLIB subclasses to still be recognized as an aspect)

conversation
Juergen Hoeller 16 years ago
parent
commit
3e63951a57
  1. 5
      org.springframework.aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java
  2. 20
      org.springframework.aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectMetadata.java

5
org.springframework.aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java

@ -112,12 +112,11 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac @@ -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.
*/
public boolean isAspect(Class<?> clazz) {
return (AjTypeSystem.getAjType(clazz).isAspect() &&
hasAspectAnnotation(clazz) && !compiledByAjc(clazz));
return (hasAspectAnnotation(clazz) && !compiledByAjc(clazz));
}
private boolean hasAspectAnnotation(Class<?> clazz) {
return clazz.isAnnotationPresent(Aspect.class);
return (AnnotationUtils.findAnnotation(clazz, Aspect.class) != null);
}
/**

20
org.springframework.aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectMetadata.java

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -67,13 +67,23 @@ public class AspectMetadata { @@ -67,13 +67,23 @@ public class AspectMetadata {
* @param aspectClass the aspect class
* @param aspectName the name of the aspect
*/
public AspectMetadata(Class aspectClass, String aspectName) {
public AspectMetadata(Class<?> aspectClass, String 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");
}
this.ajType = ajType;
if (this.ajType.getDeclarePrecedence().length > 0) {
throw new IllegalArgumentException("DeclarePrecendence not presently supported in Spring AOP");
}

Loading…
Cancel
Save