master
Juergen Hoeller 10 years ago
parent d2e269e697
commit b3add794d7
  1. 10
      spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java
  2. 23
      spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTestTypes.java
  3. 2
      spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java

@ -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;
}
}

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@ -27,24 +27,26 @@ import java.util.Set;
import javax.sql.DataSource;
import org.springframework.beans.BeansException;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.IndexedTestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.tests.sample.beans.factory.DummyFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.support.MethodReplacer;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.IndexedTestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.tests.sample.beans.factory.DummyFactory;
/**
* Types used by {@link XmlBeanFactoryTests} and its attendant XML config files.
*
* @author Chris Beams
*/
final class XmlBeanFactoryTestTypes { }
final class XmlBeanFactoryTestTypes {
}
/**
* Simple bean used to check constructor dependency checking.
@ -176,15 +178,10 @@ abstract class ConstructorInjectedOverrides {
protected abstract FactoryMethods createFactoryMethods();
/**
* @return Returns the setterString.
*/
public String getSetterString() {
return setterString;
}
/**
* @param setterString The setterString to set.
*/
public void setSetterString(String setterString) {
this.setterString = setterString;
}
@ -502,7 +499,7 @@ abstract class OverrideOneMethod extends MethodReplaceCandidate implements Overr
return new TestBean();
}
public TestBean invokesOverridenMethodOnSelf() {
public TestBean invokesOverriddenMethodOnSelf() {
return getPrototypeDependency();
}

@ -1332,7 +1332,7 @@ public final class XmlBeanFactoryTests {
// This differs from Spring's AOP support, which has a distinct notion
// of a "target" object, meaning that the target needs explicit knowledge
// of AOP proxying to invoke an advised method on itself.
TestBean jenny3 = oom.invokesOverridenMethodOnSelf();
TestBean jenny3 = oom.invokesOverriddenMethodOnSelf();
assertEquals("Jenny", jenny3.getName());
assertNotSame(jenny1, jenny3);

Loading…
Cancel
Save