Skip to content

Commit 98ac1a4

Browse files
cosmetic changes
1 parent b517158 commit 98ac1a4

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

src/main/java/spring_constructor_based_di/MainAppDemoConstructorBasedDI.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
package spring_constructor_based_di;
22

3-
/**This one is also working fine.
3+
/**
4+
* This one is also working fine.
45
* But in order to make this one work, I'll have to enable
56
* constructor-based DI in beans.xml and comment out other two DI methods in the TextEditor
6-
* and SpellChecker beans.*/
7+
* and SpellChecker beans.
8+
*/
79

810
import common.TextEditor;
911
import org.springframework.context.support.AbstractApplicationContext;
1012
import org.springframework.context.support.ClassPathXmlApplicationContext;
1113

1214
public class MainAppDemoConstructorBasedDI {
1315
public static void main(String[] args) {
14-
AbstractApplicationContext context = new ClassPathXmlApplicationContext(
15-
"beansForDemoConstructorBasedDI.xml");
16+
AbstractApplicationContext context = new ClassPathXmlApplicationContext("beansForDemoConstructorBasedDI.xml");
1617

17-
TextEditor te = (TextEditor) context.getBean("textEditor");
18+
TextEditor textEditor = (TextEditor) context.getBean("textEditor");
1819

19-
te.spellCheck();
20+
textEditor.spellCheck();
2021
context.registerShutdownHook();
2122

2223
System.out.println("Program ends.");

src/main/resources/beansForDemoBeanPostProcessor.xml

+16-16
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
<!--suppress SpringFacetInspection -->
44
<beans xmlns="http://www.springframework.org/schema/beans"
5-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6-
xsi:schemaLocation="http://www.springframework.org/schema/beans
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:schemaLocation="http://www.springframework.org/schema/beans
77
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
88

9-
<!-- I have another class called "initHelloWorld.java" which has init and
10-
destroy methods, so that I could have these properties set for this helloWolrd
11-
bean, but since the child bean "helloChina" doesn't have this class and init/destroy
12-
methods, Spring won't work if I want to init helloChina bean. -->
13-
<bean id="helloWorld" class="common.HelloWorld"
14-
init-method="init" destroy-method="destroy" lazy-init="true">
15-
<property name="message"
16-
value="Hello World from Steve Sun's very first own Spring project!" />
17-
</bean>
9+
<!-- I have another class called "initHelloWorld.java" which has init and
10+
destroy methods, so that I could have these properties set for this helloWolrd
11+
bean, but since the child bean "helloChina" doesn't have this class and init/destroy
12+
methods, Spring won't work if I want to init helloChina bean. -->
13+
<bean id="helloWorld" class="common.HelloWorld"
14+
init-method="init" destroy-method="destroy" lazy-init="true">
15+
<property name="message"
16+
value="Hello World from Steve Sun's very first own Spring project!"/>
17+
</bean>
1818

19-
<!--suppress SpringFacetInspection -->
20-
<bean id="helloChina" class="common.HelloChina"
21-
parent="helloWorld" lazy-init="true">
22-
<property name="message" value="Hello China! It is China this time!" />
23-
</bean>
19+
<!--suppress SpringFacetInspection -->
20+
<bean id="helloChina" class="common.HelloChina"
21+
parent="helloWorld" lazy-init="true">
22+
<property name="message" value="Hello China! It is China this time!"/>
23+
</bean>
2424
</beans>

src/main/resources/beansForDemoConstructorBasedDI.xml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3+
<!--suppress SpringFacetInspection -->
34
<beans xmlns="http://www.springframework.org/schema/beans"
45
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
56
xsi:schemaLocation="http://www.springframework.org/schema/beans

0 commit comments

Comments
 (0)