-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathspringConfig.xml
More file actions
126 lines (93 loc) · 4.12 KB
/
Copy pathspringConfig.xml
File metadata and controls
126 lines (93 loc) · 4.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:c="http://www.springframework.org/schema/c"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd" >
<bean class="com.simple.XMLBasedConfiguration.Alien" name="objectOfAlien" scope="singleton">
</bean>
<bean class="com.simple.XMLBasedConfiguration.Alien" name="objectOfAlienprototype" scope="prototype">
</bean>
<bean class="com.simple.XMLBasedConfiguration.Alien" name="objectOfAlienSetters" >
<property name="age" value="10"></property>
</bean>
<!--
OR using p:schema the setter injection declaration can be changed to below
<bean class="com.simple.XMLBasedConfiguration.Alien" name="objectOfAlienSetters" p:age="10" >
</bean>
-->
<bean class="com.simple.XMLBasedConfiguration.Laptop" id="laptopId" autowire="byType" >
<constructor-arg value="110"></constructor-arg>
<property name="code" ref="codeId"></property>
</bean>
<!--
Alternative way of writing the ref bean
<property name="code" ref="codeId"/>
Using P schema
p:code-ref="codeId"
-->
<bean class="com.simple.XMLBasedConfiguration.Code" id="codeId"/>
<bean class="com.simple.XMLBasedConfiguration.PythonCode" id="programmingLanguage"/>
<bean class="com.simple.XMLBasedConfiguration.JavaCode" id="javaCodeId" primary="true"/>
<bean class="com.simple.XMLBasedConfiguration.AdditionOfNumbers" id="addNumBean">
<constructor-arg value="6" />
<constructor-arg value="7" />
</bean>
<bean class="com.simple.XMLBasedConfiguration.AdditionOfNumbers" id="addNumBeanInt">
<constructor-arg value="6" type="int" index="1"/>
<constructor-arg value="7" type="int" index="0"/>
</bean>
<bean name="student" class="com.simple.XMLBasedConfiguration.Student" p:ID="4" p:Name="Harsh" p:Address="Mumbai">
<property name="list">
<list>
<value>100</value>
<value>200</value>
</list>
</property>
<property name="set">
<set>
<value>100</value>
<value>200</value>
<value>100</value>
</set>
</property>
<property name="map">
<map>
<entry key="Java" value="1"/>
<entry key="Python" value="2"/>
</map>
</property>
<property name="MyProps">
<props>
<prop key="prop1">value1</prop>
<prop key="prop2">value2</prop>
</props>
</property>
</bean>
<!-- Standalone List -->
<!-- To enabled downloading of external references go to windows -> preferences -> XML allow download -->
<util:list list-class="java.util.LinkedList" id="myList">
<value>1</value>
<value>2</value>
<value>3</value>
</util:list>
<util:map map-class="java.util.TreeMap" id="myMap">
<entry key="123" value="11" />
<entry key="124" value="22" />
</util:map>
<util:properties id="myProps">
<prop key="dbDriver">sqlDriverPath</prop>
</util:properties>
<bean name="employee" class="com.simple.XMLBasedConfiguration.Employee" >
<property name="list" ref="myList"/>
<property name="map" ref="myMap"/>
<property name="MyProps" ref="myProps"/>
</bean>
</beans>