You are on page 1of 32

Java Course

Module 18: Case Study

Module Objectives
At the end of this module, participants will be able to:
Describe the application architecture used by the case study
application
Identify and describe the deliverables that must be provided in order
to complete the case study
Identify and describe the roles, responsibilities, and deliverables of a
developer during this case study

Case Study Overview


The case-study application is a simple Employee database
application.
Participants will be expected to complete the implementation the
requirements of the application based on the provided design
documentation.
Spring, Subversion, Tomcat, Tortoise, and Subclipse will be
used in the Case Study.
The License Agreements of these OSS are found in the
Appendix section of this module.

Case Study Inputs


A developer handbook (this presentation) containing high level
architecture and design information.
Partially implemented skeleton of the application to serve as a
guide and sample on the rest of the requirements.

Case Study Outputs


Design, document and implement the physical data model
required to support application requirements.
Create TCERs required by the interface layer according to its
documentation.
Complete implementation of JUnit test classes based on the
TCERs generated for the repository and service objects.
Complete implementation of the repository and the service
objects based on the requirements of the interface layer and the
JUnit test classes.

Application Overview
The application is a simulation of an Employee database
containing records of an Employees basic profile, projects and
skills.
The application provides the ability for a user to search for
employees via their names or their projects and to obtain details
on their project history and skill set.

Application Use-Cases

Application Overview

HRS Services

Repositories

Spring Dependency Injection

Spring MVC

Domain Objects

Repositories are the various data


access classes that provide CRUD
(Create, Read, Update, Delete)
functionality for value objects that need
to be maintained
Services represent the business layer
of the application and is a
representation of the various use-cases
of the application
Domain Objects represent the logical
data model for the application.
Spring MVC is used to implements the
applications web presentation layer
Spring Framework is used for its
dependency injection feature that
allows different implementations across
all layers to be plugged in without
referencing them in code

MySQL Database

Sequence Diagram
JSP

Controller

Service

Repository

Database

Web page sends request to


controller handler
Controller handler calls
service API
Service API calls
repository methods
Repository queries
database
Return Result

Return Result

Return data model


Determine what page
to display

Logical Data Model


The applications logical data model represents the relationships
between the different domain objects
The service and repository methods return objects of these
types
1

Employee
1
Project

EmployeeDetail

EmployeeProjectDetail

N
ProjectRole
N
EmployeeSkill
* Contains

10

Logical Data Model


EmployeeDetail a combination of the different domain objects.
This represents information about a specific employee, the
employees project history and the employees skill set.
Employee basic information about a single employee.
EmployeeSkill information on a specific skill of an employee.
EmployeeProjectDetail a collection of project roles of an
employee for a specific project.
Project basic information about a single project.
ProjectRole basic information about a specific project role.

11

Current State of the Application


The applications presentation layer is currently implemented
and functional
The service layers are currently implemented as stubs

Services (Stub)

Controllers

JSP

Repository

Data Layer

Presentation Layer

MySQL Database

For implementation

12

TODOs
Design, document, and implement a database schema that
represents the information and relationships the applications
logical data model at a database level.
Design and implement repository classes that will provide
access to the information stored in the database.
Re-implement the stub service classes in order to make use of
the repositories to access its data instead of returning dummy
data.

13

TODOs
Complete the Functional Test plan. A partially implemented test
plan is already provided for you:

Create TCERs for each class/API implemented


Create JUnits for each class/API implemented

14

Hints
Make sure you understand the definitions and the relationships
described by the logical data model. This will greatly influence
the way that you design the database schema.
Pay careful attention to the requirements of the service layer.
This will determine what kind of data the service layer will accept
from the controller, and what kind of data will be returned. This
will influence how you design your repositories (DAOs).
Make sure the design and interface across layers are properly
understood. Know what parameters to send, and what values to
expect (refer to the sequence diagram).

15

Spring Dependency Injection


The application makes use of Springs dependency injection
feature extensively across all layers.
The framework allows objects to have their dependencies
injected into them instead of requiring objects to declare their
object dependencies in their own code.
By freeing the object from having to declare its dependencies, it
can focus on its functional and business behavior while
minimizing implementation specific code.

16

Example: DAOs and Datasources


DAO (Data Access Object) implementations typically require a
DataSource reference in order to access the database.
The DataSource object is used to establish connections with a
specific database instance.
DAO
MySQL Database

DataSource

17

Dependency Declaration
One approach would be for the DAO itself to have code that
constructs a DataSource that connects to a specific database
instance.
This approach will lock the DAO to that specific database
instance. If the database changes, the DAO would have to be
recoded and recompiled.

18

Dependency Injection
The dependency injection
approach injects the
DataSource into the DAO
through external configuration
files.
The DAO class itself is not
concerned how it gets a
DataSource object and does
not have any implementation
specific code needed to get a
DAO reference.
The DAO can have different
DataSource implementations
injected as required without
having to change its code

MySQL
Database

DataSource
Implementation
DAO
DataSource

Oracle
Database

DataSource
Implementation

19

Dependency Injection
Dependency injection is configured through XML-based
configuration files.
Each configuration file defines beans which are objects that we
want the Spring framework to manage.
The dependencies between beans are configured through the
xml (called wiring beans).

20

Example: Create a Bean


The following declares a bean named dataSource, which represents an
instance of a dataSource object.
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value=com.mysql.jdbc.Driver./>
<property name="url" value=jdbc:mysql:localhost:3128/schema
<property name="username" value=root/>
<property name="password" value=abcd1234"/>
</bean>

The property name element represents the objects various setter


methods and the values that are passed to them allowing these values to
be injected.
property name name=username value=root corresponds to the objects
setUsername(root) method being called.
An object can also be passed values through its construct by using
<constructor-arg> tag instead of <property>.
21

Example: Create a Bean


The following xml configuration shows how to inject a bean as the dependency of
another bean. In this case a repository (DAO) bean is injected a reference to a
datasource bean:
<bean id="employeeRep" class=sef.impl.repository.JDBCEmployeeRepositoryImpl" >
<constructor-arg ref="dataSource"/>
</bean>

Note that the ref property is used instead of the value property. This means
that the it is injecting a reference to another bean.

22

Example: Create a Bean


In order to obtain a reference to a bean in code, we use the
ApplicationContext and pass it the location of the xml config files.
ApplicationContext context = new
ClassPathXmlApplicationContext("classpath:repository-config.xml");
Once a context is retrieved, it can be used to obtain a reference to any
bean that is inside the declared inside the xml.
service = (SearchService)context.getBean("searchService");

23

Application Config Files


The application has two configuration files:
config/repository-config.xml This contains beans for the data layer of
the application. This is currently populated with stub classes which will
need to be modified and replaced with the beans required for the data
layer (services, datasources and repositories) of the application that you
will be implementing.
Web-INF/mvc-config.xml This contains controller definitions and wires
the various services to the web-ui controller. This document need not be
modified.
There should be no need to create additional configuration files. Just
place any beans where appropriate

24

Schedule

The succeeding slides


will show the schedule of activities

25

Schedule

26

Schedule

27

Schedule

28

Schedule
DAY 20 : Removal of Open Source Software
Everyone is expected to remove the following OSS from the
workstation:
Eclipse 3.4
JDK 1.6
MySQL 5.0
Spring 5.0

Subeclipse 1.4.x
Subversion 1.5.x
Tomcat 6.0.16
Tortoise 1.5.3.13783

29

Appendix
Spring
Version
License

: 2.5.5
: http://www.apache.org/licenses/LICENSE-2.0.html

Subversion
Version
License

: 1.5.2
: http://subversion.tigris.org/license-1.html

Tomcat
Version
License

: 6.0.16
: http://www.apache.org/licenses/LICENSE-2.0

30

Appendix
Tortoise
Version
License

: 1.5.3.13783
: http://www.opensource.org/licenses/gpl-license.php

Subeclipse
Version
License

: 1.4.x
: http://www.eclipse.org/legal/epl-v10.html

31

Questions and Comments

32

You might also like