From 4b30fe2b44f197e461a34fce85c8569880a141be Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 9 Aug 2018 02:30:10 +0200 Subject: [PATCH] Polishing --- .../AbstractAspectJAdvisorFactory.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java index e12d9f150e5..84ed4638738 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java @@ -60,7 +60,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac private static final String AJC_MAGIC = "ajc$"; private static final Class[] ASPECTJ_ANNOTATION_CLASSES = new Class[] { - Pointcut.class, Before.class, Around.class, After.class, AfterReturning.class, AfterThrowing.class}; + Pointcut.class, Around.class, Before.class, After.class, AfterReturning.class, AfterThrowing.class}; /** Logger available to subclasses */ @@ -150,16 +150,12 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac /** - * AspectJ annotation types. + * Enum for AspectJ annotation types. + * @see AspectJAnnotation#getAnnotationType() */ protected enum AspectJAnnotationType { - AtPointcut, - AtBefore, - AtAfter, - AtAfterReturning, - AtAfterThrowing, - AtAround + AtPointcut, AtAround, AtBefore, AtAfter, AtAfterReturning, AtAfterThrowing } @@ -176,11 +172,11 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac static { annotationTypeMap.put(Pointcut.class, AspectJAnnotationType.AtPointcut); + annotationTypeMap.put(Around.class, AspectJAnnotationType.AtAround); annotationTypeMap.put(Before.class, AspectJAnnotationType.AtBefore); annotationTypeMap.put(After.class, AspectJAnnotationType.AtAfter); annotationTypeMap.put(AfterReturning.class, AspectJAnnotationType.AtAfterReturning); annotationTypeMap.put(AfterThrowing.class, AspectJAnnotationType.AtAfterThrowing); - annotationTypeMap.put(Around.class, AspectJAnnotationType.AtAround); } private final A annotation; @@ -194,8 +190,6 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac public AspectJAnnotation(A annotation) { this.annotation = annotation; this.annotationType = determineAnnotationType(annotation); - // We know these methods exist with the same name on each object, - // but need to invoke them reflectively as there isn't a common interface. try { this.pointcutExpression = resolveExpression(annotation); this.argumentNames = (String) AnnotationUtils.getValue(annotation, "argNames"); @@ -261,11 +255,11 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac if (annotation == null) { return null; } - StringTokenizer strTok = new StringTokenizer(annotation.getArgumentNames(), ","); - if (strTok.countTokens() > 0) { - String[] names = new String[strTok.countTokens()]; + StringTokenizer nameTokens = new StringTokenizer(annotation.getArgumentNames(), ","); + if (nameTokens.countTokens() > 0) { + String[] names = new String[nameTokens.countTokens()]; for (int i = 0; i < names.length; i++) { - names[i] = strTok.nextToken(); + names[i] = nameTokens.nextToken(); } return names; }