0% found this document useful (0 votes)
9 views2 pages

Spring Day02 Task

The document outlines the development of three Spring Core applications involving dependency injection using XML configuration. The first application involves a Person class with an Address object, the second involves a Library class containing a list of Book objects, and the third involves a Company class with multiple Department objects. Each application specifies the required attributes, methods, and XML configurations for bean definitions and injections.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Spring Day02 Task

The document outlines the development of three Spring Core applications involving dependency injection using XML configuration. The first application involves a Person class with an Address object, the second involves a Library class containing a list of Book objects, and the third involves a Company class with multiple Department objects. Each application specifies the required attributes, methods, and XML configurations for bean definitions and injections.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Question 1: Person and Address Injection:

=========================================
You are tasked with developing a Spring Core application where a Person object has
an Address object injected using setter-based dependency injection.

Requirements:
--------------
Address Class:
--------------

Attributes:
-----------
.String city
.String country
.Setter methods for both fields.

Person Class:
--------------

Attributes:
------------
.String name
.Address address
.Setter methods for both fields.
.A method displayInfo() that prints the person's name and address (city, country).

Note:
------
Use an XML file to:
-------------------

.Define both Person and Address beans.


.Inject the Address bean into the Person bean via setter.

Main Class:
------------
Load Spring context, get Person bean, call displayInfo().

Question 2: Library and Books Injection:


=========================================
You are tasked with developing a Spring Core application where a Library contains a
list of Book objects injected using setter-based dependency injection.

Requirements:
Book Class:

Attributes:
String title
String author
Setter methods for both.

Library Class:

Attributes:
List<Book> books
Setter method to inject the list of books.
Method displayBooks() to print all book titles and authors.
Note:
Use an XML file to:

Create multiple Book beans.

Inject them as a list into the Library bean using <list>.

Main Class:

Load Spring context, retrieve Library bean, and call displayBooks().

Question 3: Company and Multiple Departments Injection:


=======================================================
You are tasked with developing a Spring Core application where a Company has
multiple Department objects injected via setter-based dependency injection.

Requirements:

Department Class:

Attributes:

String deptName

int deptId

Setter methods.

Company Class:

Attributes:

List<Department> departments

Setter method.

A showDepartments() method that prints all department names and IDs.

Note:

Define Department beans and inject them into the Company bean using list collection
in XML.

Main Class:

Load context, get Company bean, and call showDepartments().

You might also like