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); this.typeIdentifiers.add(identifier);
} }
@Override @Override
public boolean matches(Method method) { public boolean matches(Method method) {
// TODO could cache result for efficiency
if (!method.getName().equals(getMethodName())) { if (!method.getName().equals(getMethodName())) {
// It can't match.
return false; return false;
} }
if (!isOverloaded()) { if (!isOverloaded()) {
// No overloaded: don't worry about arg type matching. // Not overloaded: don't worry about arg type matching...
return true; return true;
} }
// If we get here, we need to insist on precise argument matching...
// If we get to here, we need to insist on precise argument matching.
if (this.typeIdentifiers.size() != method.getParameterTypes().length) { if (this.typeIdentifiers.size() != method.getParameterTypes().length) {
return false; return false;
} }
for (int i = 0; i < this.typeIdentifiers.size(); i++) { for (int i = 0; i < this.typeIdentifiers.size(); i++) {
String identifier = this.typeIdentifiers.get(i); String identifier = this.typeIdentifiers.get(i);
if (!method.getParameterTypes()[i].getName().contains(identifier)) { if (!method.getParameterTypes()[i].getName().contains(identifier)) {
// This parameter cannot match.
return false; 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 javax.sql.DataSource;
import org.springframework.beans.BeansException; 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.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean; 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.InitializingBean;
import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.support.MethodReplacer; 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. * Types used by {@link XmlBeanFactoryTests} and its attendant XML config files.
* *
* @author Chris Beams * @author Chris Beams
*/ */
final class XmlBeanFactoryTestTypes { } final class XmlBeanFactoryTestTypes {
}
/** /**
* Simple bean used to check constructor dependency checking. * Simple bean used to check constructor dependency checking.
@ -176,15 +178,10 @@ abstract class ConstructorInjectedOverrides {
protected abstract FactoryMethods createFactoryMethods(); protected abstract FactoryMethods createFactoryMethods();
/**
* @return Returns the setterString.
*/
public String getSetterString() { public String getSetterString() {
return setterString; return setterString;
} }
/**
* @param setterString The setterString to set.
*/
public void setSetterString(String setterString) { public void setSetterString(String setterString) {
this.setterString = setterString; this.setterString = setterString;
} }
@ -502,7 +499,7 @@ abstract class OverrideOneMethod extends MethodReplaceCandidate implements Overr
return new TestBean(); return new TestBean();
} }
public TestBean invokesOverridenMethodOnSelf() { public TestBean invokesOverriddenMethodOnSelf() {
return getPrototypeDependency(); return getPrototypeDependency();
} }

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

Loading…
Cancel
Save