Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Dec 13, 2023
1 parent a612518 commit d440650
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,14 @@ private Object resolveValue(RegisteredBean registeredBean, Field field) {
return value;
}
catch (BeansException ex) {
throw new UnsatisfiedDependencyException(null, beanName,
new InjectionPoint(field), ex);
throw new UnsatisfiedDependencyException(null, beanName, new InjectionPoint(field), ex);
}
}

private Field getField(RegisteredBean registeredBean) {
Field field = ReflectionUtils.findField(registeredBean.getBeanClass(),
this.fieldName);
Assert.notNull(field, () -> "No field '" + this.fieldName + "' found on "
+ registeredBean.getBeanClass().getName());
Field field = ReflectionUtils.findField(registeredBean.getBeanClass(), this.fieldName);
Assert.notNull(field, () -> "No field '" + this.fieldName + "' found on " +
registeredBean.getBeanClass().getName());
return field;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;

/**
* Tests for {@code ResourceFieldValueResolver}.
* Tests for {@link ResourceElementResolver} with fields.
*
* @author Stephane Nicoll
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;

/**
* Tests for {@code ResourceMethodArgumentResolver}.
* Tests for {@link ResourceElementResolver} with methods.
*
* @author Stephane Nicoll
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<!--
Not yet in use: illustration of possible approach
-->
<bean id="overrideOneMethod" class="org.springframework.beans.factory.xml.OverrideOneMethod">

<lookup-method name="getPrototypeDependency" bean="jenny"/>
Expand All @@ -27,48 +24,34 @@

<lookup-method name="protectedOverrideSingleton" bean="david"/>

<!--
This method is not overloaded, so we don't need to specify any arg types
-->
<!-- This method is not overloaded, so we don't need to specify any arg types -->
<replaced-method name="doSomething" replacer="doSomethingReplacer"/>

</bean>

<bean id="replaceVoidMethod" parent="someParent"
class="org.springframework.beans.factory.xml.OverrideOneMethodSubclass">
</bean>
<bean id="replaceVoidMethod" parent="someParent" class="org.springframework.beans.factory.xml.OverrideOneMethodSubclass"/>

<bean id="replaceEchoMethod" class="org.springframework.beans.factory.xml.EchoService">
<!--
This method is not overloaded, so we don't need to specify any arg types
-->
<!-- This method is not overloaded, so we don't need to specify any arg types -->
<replaced-method name="echo" replacer="reverseArrayReplacer" />
</bean>

<bean id="reverseReplacer"
class="org.springframework.beans.factory.xml.ReverseMethodReplacer"/>

<bean id="reverseArrayReplacer"
class="org.springframework.beans.factory.xml.ReverseArrayMethodReplacer"/>
<bean id="reverseReplacer" class="org.springframework.beans.factory.xml.ReverseMethodReplacer"/>

<bean id="fixedReplacer"
class="org.springframework.beans.factory.xml.FixedMethodReplacer"/>
<bean id="reverseArrayReplacer" class="org.springframework.beans.factory.xml.ReverseArrayMethodReplacer"/>

<bean id="doSomethingReplacer"
class="org.springframework.beans.factory.xml.XmlBeanFactoryTests$DoSomethingReplacer"/>
<bean id="fixedReplacer" class="org.springframework.beans.factory.xml.FixedMethodReplacer"/>

<bean id="serializableReplacer"
class="org.springframework.beans.factory.xml.SerializableMethodReplacerCandidate">
<bean id="doSomethingReplacer" class="org.springframework.beans.factory.xml.XmlBeanFactoryTests$DoSomethingReplacer"/>

<bean id="serializableReplacer" class="org.springframework.beans.factory.xml.SerializableMethodReplacerCandidate">
<!-- Arbitrary method replacer -->
<replaced-method name="replaceMe" replacer="reverseReplacer">
<arg-type>String</arg-type>
</replaced-method>

</bean>

<bean id="jenny" class="org.springframework.beans.testfixture.beans.TestBean"
scope="prototype">
<bean id="jenny" class="org.springframework.beans.testfixture.beans.TestBean" scope="prototype">
<property name="name"><value>Jenny</value></property>
<property name="age"><value>30</value></property>
<property name="spouse">
Expand All @@ -77,8 +60,7 @@
</property>
</bean>

<bean id="david" class="org.springframework.beans.testfixture.beans.TestBean"
scope="singleton">
<bean id="david" class="org.springframework.beans.testfixture.beans.TestBean" scope="singleton">
<description>
Simple bean, without any collections.
</description>
Expand Down

0 comments on commit d440650

Please sign in to comment.