Browse Source

Polishing

pull/622/head
Juergen Hoeller 12 years ago
parent
commit
0c0d23d0f4
  1. 10
      spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java
  2. 2
      spring-context/src/test/java/org/springframework/context/annotation/BeanMethodPolymorphismTests.java

10
spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java

@ -69,28 +69,22 @@ public class ReplaceOverride extends MethodOverride { @@ -69,28 +69,22 @@ public class ReplaceOverride extends MethodOverride {
this.typeIdentifiers.add(identifier);
}
@Override
public boolean matches(Method method) {
// TODO could cache result for efficiency
if (!method.getName().equals(getMethodName())) {
// It can't match.
return false;
}
if (!isOverloaded()) {
// No overloaded: don't worry about arg type matching.
// Not overloaded: don't worry about arg type matching...
return true;
}
// If we get to here, we need to insist on precise argument matching.
// If we get here, we need to insist on precise argument matching...
if (this.typeIdentifiers.size() != method.getParameterTypes().length) {
return false;
}
for (int i = 0; i < this.typeIdentifiers.size(); i++) {
String identifier = this.typeIdentifiers.get(i);
if (!method.getParameterTypes()[i].getName().contains(identifier)) {
// This parameter cannot match.
return false;
}
}

2
spring-context/src/test/java/org/springframework/context/annotation/BeanMethodPolymorphismTests.java

@ -250,7 +250,7 @@ public class BeanMethodPolymorphismTests { @@ -250,7 +250,7 @@ public class BeanMethodPolymorphismTests {
return "regular";
}
@Bean
@Bean @Lazy
String aString(Integer dependency) {
return "overloaded" + dependency;
}

Loading…
Cancel
Save