Resolved SPR-6618. Restrictions were too tight on overloaded bean methods and were preventing it altogether. Overloading is now allowed, as long as there is no ambiguity at runtime which bean method should be invoked.

This commit is contained in:
Chris Beams
2009-12-30 19:42:12 +00:00
parent 75d0f9b95c
commit d1b3f57320
9 changed files with 146 additions and 47 deletions

View File

@@ -24,6 +24,7 @@ import java.util.Map;
*
* @author Juergen Hoeller
* @author Mark Pollack
* @author Chris Beams
* @since 3.0
* @see StandardMethodMetadata
* @see AnnotationMetadata#getAnnotatedMethods
@@ -35,6 +36,11 @@ public interface MethodMetadata {
*/
String getMethodName();
/**
* Return the fully-qualified name of the class that declares this method.
*/
public String getDeclaringClassName();
/**
* Return whether the underlying method is declared as 'static'.
*/

View File

@@ -30,6 +30,7 @@ import org.springframework.util.Assert;
*
* @author Juergen Hoeller
* @author Mark Pollack
* @author Chris Beams
* @since 3.0
*/
public class StandardMethodMetadata implements MethodMetadata {
@@ -53,10 +54,14 @@ public class StandardMethodMetadata implements MethodMetadata {
return this.introspectedMethod;
}
public String getMethodName() {
return this.introspectedMethod.getName();
}
public String getDeclaringClassName() {
return this.introspectedMethod.getDeclaringClass().getName();
}
public boolean isStatic() {
return Modifier.isStatic(this.introspectedMethod.getModifiers());

View File

@@ -57,7 +57,7 @@ final class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisitor
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
MethodMetadataReadingVisitor mm = new MethodMetadataReadingVisitor(name, access, this.classLoader);
MethodMetadataReadingVisitor mm = new MethodMetadataReadingVisitor(name, access, this.getClassName(), this.classLoader);
this.methodMetadataSet.add(mm);
return mm;
}

View File

@@ -41,15 +41,18 @@ final class MethodMetadataReadingVisitor extends MethodAdapter implements Method
private final int access;
private String declaringClassName;
private final ClassLoader classLoader;
private final Map<String, Map<String, Object>> attributeMap = new LinkedHashMap<String, Map<String, Object>>();
public MethodMetadataReadingVisitor(String name, int access, ClassLoader classLoader) {
public MethodMetadataReadingVisitor(String name, int access, String declaringClassName, ClassLoader classLoader) {
super(new EmptyVisitor());
this.name = name;
this.access = access;
this.declaringClassName = declaringClassName;
this.classLoader = classLoader;
}
@@ -85,4 +88,8 @@ final class MethodMetadataReadingVisitor extends MethodAdapter implements Method
return this.attributeMap.get(annotationType);
}
public String getDeclaringClassName() {
return this.declaringClassName;
}
}