File tree Expand file tree Collapse file tree 3 files changed +28
-7
lines changed
main/java/org/springframework/beans/factory/support
java/org/springframework/beans/factory/support
resources/org/springframework/beans/factory/support Expand file tree Collapse file tree 3 files changed +28
-7
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright 2002-2012 the original author or authors.
2+ * Copyright 2002-2015 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1818
1919import java .lang .reflect .Method ;
2020import java .util .HashSet ;
21+ import java .util .LinkedHashSet ;
2122import java .util .Set ;
2223
2324/**
3435 */
3536public class MethodOverrides {
3637
37- private final Set <MethodOverride > overrides = new HashSet <MethodOverride >(0 );
38+ private final Set <MethodOverride > overrides = new LinkedHashSet <MethodOverride >(0 );
3839
3940
4041 /**
@@ -89,14 +90,16 @@ public boolean isEmpty() {
8990 * @return the method override, or {@code null} if none
9091 */
9192 public MethodOverride getOverride (Method method ) {
92- for (MethodOverride override : this .overrides ) {
93- if (override .matches (method )) {
94- return override ;
93+ MethodOverride match = null ;
94+ for (MethodOverride candidate : this .overrides ) {
95+ if (candidate .matches (method )) {
96+ match = candidate ;
9597 }
9698 }
97- return null ;
99+ return match ;
98100 }
99101
102+
100103 @ Override
101104 public boolean equals (Object other ) {
102105 if (this == other ) {
Original file line number Diff line number Diff line change 11/*
2- * Copyright 2002-2014 the original author or authors.
2+ * Copyright 2002-2015 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -90,6 +90,16 @@ public void testWithThreeArgsShouldFail() {
9090 }
9191 }
9292
93+ @ Test
94+ public void testWithOverriddenLookupMethod () {
95+ AbstractBean bean = (AbstractBean ) beanFactory .getBean ("extendedBean" );
96+ assertNotNull (bean );
97+ TestBean expected = bean .getOneArgument ("haha" );
98+ assertEquals (TestBean .class , expected .getClass ());
99+ assertEquals ("haha" , expected .getName ());
100+ assertTrue (expected .isJedi ());
101+ }
102+
93103
94104 public static abstract class AbstractBean {
95105
Original file line number Diff line number Diff line change 99 <lookup-method name =" getTwoArguments" bean =" testBean" />
1010 </bean >
1111
12+ <bean id =" extendedBean" parent =" abstractBean" >
13+ <lookup-method name =" getOneArgument" bean =" jedi" />
14+ </bean >
15+
1216 <bean id =" testBean" class =" org.springframework.tests.sample.beans.TestBean" scope =" prototype" />
1317
18+ <bean id =" jedi" class =" org.springframework.tests.sample.beans.TestBean" scope =" prototype" autowire-candidate =" false" >
19+ <property name =" jedi" value =" true" />
20+ </bean >
21+
1422</beans >
You can’t perform that action at this time.
0 commit comments