Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Dec 14, 2023
1 parent 67e0310 commit ccaecab
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 @@ -731,7 +731,7 @@ public String[] getAliases(String name) {
aliases.add(fullBeanName);
}
String[] retrievedAliases = super.getAliases(beanName);
String prefix = factoryPrefix ? FACTORY_BEAN_PREFIX : "";
String prefix = (factoryPrefix ? FACTORY_BEAN_PREFIX : "");
for (String retrievedAlias : retrievedAliases) {
String alias = prefix + retrievedAlias;
if (!alias.equals(name)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
/** Flag that indicates whether this context has been closed already. */
private final AtomicBoolean closed = new AtomicBoolean();

/** Synchronization monitor for the "refresh" and "destroy". */
/** Synchronization monitor for "refresh" and "close". */
private final Object startupShutdownMonitor = new Object();

/** Reference to the JVM shutdown hook, if registered. */
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 ccaecab

Please sign in to comment.