1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+
3
+ <beans xmlns =" http://www.springframework.org/schema/beans"
4
+ xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
5
+ xmlns:context=" http://www.springframework.org/schema/context"
6
+ xsi:schemaLocation=" http://www.springframework.org/schema/beans
7
+ http://www.springframework.org/schema/beans/spring-beans.xsd
8
+ http://www.springframework.org/schema/context
9
+ http://www.springframework.org/schema/context/spring-context.xsd" >
10
+
11
+ <!-- Define beans using annotations -->
12
+ <context : component-scan
13
+ base-package=" com.example" ></context : component-scan >
14
+
15
+ <!-- Inversion of control -->
16
+ <bean id =" accountantXml" class =" com.example.Accountant" ></bean >
17
+ <bean id =" secuirtyGuardXml" class =" com.example.SecurityGuard" ></bean >
18
+
19
+ <!-- Constructor Injection -->
20
+ <bean id =" accountantDepartmentXml"
21
+ class=" com.example.AccountingDepartment" ></bean >
22
+
23
+ <bean id =" accountantConstructorXml" class =" com.example.Accountant" >
24
+ <constructor-arg index =" 0" value =" Ahmed Osama Tantawy" />
25
+ <constructor-arg index =" 1"
26
+ ref=" accountantDepartmentXml" />
27
+ </bean >
28
+
29
+ <!-- Setter Injection -->
30
+
31
+ <bean id =" securityDepartmentXml"
32
+ class=" com.example.SecurityDepartment" ></bean >
33
+
34
+ <bean id =" securitySetterXml" class =" com.example.SecurityGuard" >
35
+ <property name =" employeeName" value =" Ahmed Osama Tantawy" ></property >
36
+ <property name =" department" ref =" securityDepartmentXml" ></property >
37
+ </bean >
38
+
39
+
40
+ </beans >
0 commit comments