From 0ea17c83823a9bb442a0f01f6f8480710ab10408 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 30 Apr 2013 21:31:22 +0200 Subject: [PATCH] Allow for reuse of key visitor classes in tooling Based on https://github.com/SpringSource/spring-framework/pull/263 --- .../AnnotationMetadataReadingVisitor.java | 12 +++++----- .../MethodMetadataReadingVisitor.java | 22 +++++++++++-------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java index 982534a3795..72bf34bbbcb 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java @@ -43,17 +43,17 @@ import org.springframework.util.MultiValueMap; * @author Costin Leau * @since 2.5 */ -final class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisitor implements AnnotationMetadata { +public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisitor implements AnnotationMetadata { - private final ClassLoader classLoader; + protected final ClassLoader classLoader; - private final Set annotationSet = new LinkedHashSet(); + protected final Set annotationSet = new LinkedHashSet(); - private final Map> metaAnnotationMap = new LinkedHashMap>(4); + protected final Map> metaAnnotationMap = new LinkedHashMap>(4); - private final Map attributeMap = new LinkedHashMap(4); + protected final Map attributeMap = new LinkedHashMap(4); - private final MultiValueMap methodMetadataMap = new LinkedMultiValueMap(); + protected final MultiValueMap methodMetadataMap = new LinkedMultiValueMap(); public AnnotationMetadataReadingVisitor(ClassLoader classLoader) { diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java index 58256b6049d..4b39bbaea7b 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -39,22 +39,24 @@ import org.springframework.util.MultiValueMap; * @author Chris Beams * @since 3.0 */ -final class MethodMetadataReadingVisitor extends MethodVisitor implements MethodMetadata { +public class MethodMetadataReadingVisitor extends MethodVisitor implements MethodMetadata { - private final String name; + protected final String name; - private final int access; + protected final int access; - private String declaringClassName; + protected final String declaringClassName; - private final ClassLoader classLoader; + protected final ClassLoader classLoader; - private final MultiValueMap methodMetadataMap; + protected final MultiValueMap methodMetadataMap; + + protected final Map attributeMap = new LinkedHashMap(2); - private final Map attributeMap = new LinkedHashMap(2); public MethodMetadataReadingVisitor(String name, int access, String declaringClassName, ClassLoader classLoader, MultiValueMap methodMetadataMap) { + super(SpringAsmInfo.ASM_VERSION); this.name = name; this.access = access; @@ -63,10 +65,11 @@ final class MethodMetadataReadingVisitor extends MethodVisitor implements Method this.methodMetadataMap = methodMetadataMap; } + @Override public AnnotationVisitor visitAnnotation(final String desc, boolean visible) { String className = Type.getType(desc).getClassName(); - methodMetadataMap.add(className, this); + this.methodMetadataMap.add(className, this); return new AnnotationAttributesReadingVisitor(className, this.attributeMap, null, this.classLoader); } @@ -97,4 +100,5 @@ final class MethodMetadataReadingVisitor extends MethodVisitor implements Method public String getDeclaringClassName() { return this.declaringClassName; } + }