Browse Source

MethodMetadata exposes method return type

Issue: SPR-13024
pull/799/merge
Juergen Hoeller 10 years ago
parent
commit
1e7d954fcb
  1. 8
      spring-core/src/main/java/org/springframework/core/type/MethodMetadata.java
  2. 5
      spring-core/src/main/java/org/springframework/core/type/StandardMethodMetadata.java
  3. 3
      spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java
  4. 18
      spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java

8
spring-core/src/main/java/org/springframework/core/type/MethodMetadata.java

@ -39,7 +39,13 @@ public interface MethodMetadata extends AnnotatedTypeMetadata { @@ -39,7 +39,13 @@ public interface MethodMetadata extends AnnotatedTypeMetadata {
/**
* Return the fully-qualified name of the class that declares this method.
*/
public String getDeclaringClassName();
String getDeclaringClassName();
/**
* Return the fully-qualified name of this method's declared return type.
* @since 4.2
*/
String getReturnTypeName();
/**
* Return whether the underlying method is effectively abstract:

5
spring-core/src/main/java/org/springframework/core/type/StandardMethodMetadata.java

@ -84,6 +84,11 @@ public class StandardMethodMetadata implements MethodMetadata { @@ -84,6 +84,11 @@ public class StandardMethodMetadata implements MethodMetadata {
return this.introspectedMethod.getDeclaringClass().getName();
}
@Override
public String getReturnTypeName() {
return this.introspectedMethod.getReturnType().getName();
}
@Override
public boolean isAbstract() {
return Modifier.isAbstract(this.introspectedMethod.getModifiers());

3
spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java

@ -76,7 +76,8 @@ public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisito @@ -76,7 +76,8 @@ public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisito
if ((access & Opcodes.ACC_BRIDGE) != 0) {
return super.visitMethod(access, name, desc, signature, exceptions);
}
return new MethodMetadataReadingVisitor(name, access, getClassName(), this.classLoader, this.methodMetadataSet);
return new MethodMetadataReadingVisitor(name, access, getClassName(),
Type.getReturnType(desc).getClassName(), this.classLoader, this.methodMetadataSet);
}
@Override

18
spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java

@ -44,12 +44,14 @@ import org.springframework.util.MultiValueMap; @@ -44,12 +44,14 @@ import org.springframework.util.MultiValueMap;
*/
public class MethodMetadataReadingVisitor extends MethodVisitor implements MethodMetadata {
protected final String name;
protected final String methodName;
protected final int access;
protected final String declaringClassName;
protected final String returnTypeName;
protected final ClassLoader classLoader;
protected final Set<MethodMetadata> methodMetadataSet;
@ -58,13 +60,14 @@ public class MethodMetadataReadingVisitor extends MethodVisitor implements Metho @@ -58,13 +60,14 @@ public class MethodMetadataReadingVisitor extends MethodVisitor implements Metho
new LinkedMultiValueMap<String, AnnotationAttributes>(4);
public MethodMetadataReadingVisitor(String name, int access, String declaringClassName,
ClassLoader classLoader, Set<MethodMetadata> methodMetadataSet) {
public MethodMetadataReadingVisitor(String methodName, int access, String declaringClassName,
String returnTypeName, ClassLoader classLoader, Set<MethodMetadata> methodMetadataSet) {
super(SpringAsmInfo.ASM_VERSION);
this.name = name;
this.methodName = methodName;
this.access = access;
this.declaringClassName = declaringClassName;
this.returnTypeName = returnTypeName;
this.classLoader = classLoader;
this.methodMetadataSet = methodMetadataSet;
}
@ -79,7 +82,7 @@ public class MethodMetadataReadingVisitor extends MethodVisitor implements Metho @@ -79,7 +82,7 @@ public class MethodMetadataReadingVisitor extends MethodVisitor implements Metho
@Override
public String getMethodName() {
return this.name;
return this.methodName;
}
@Override
@ -144,4 +147,9 @@ public class MethodMetadataReadingVisitor extends MethodVisitor implements Metho @@ -144,4 +147,9 @@ public class MethodMetadataReadingVisitor extends MethodVisitor implements Metho
return this.declaringClassName;
}
@Override
public String getReturnTypeName() {
return this.returnTypeName;
}
}

Loading…
Cancel
Save