A multi tier CD catalog management application

Purpose of the example

Our recurrent example consist in building a CD catalog management application. It will be use by many tutorials on this site such as the Struts framework tutorial, the HSQLDB tutorial, an others... We will use a multi tier model so that each tutorial can focus on its concerns only. For example, a database tutorial will focus on the data access and not on the user interface.

UML modelisation

A CD catalog is a set of CD with wich a user can interact : he can add a CD to the catalog, get all the CDs of the desired artist, remove a CD from the catalog, ... Here, we will limit the interaction to 7 possible actions :

CD catalog UML use case
Use case diagram

addToCatalog
Allow the user to add a CD to the catalog.
getById
Allow the user to retrieve a CD from the catalog according to it's id.
updateInCatalog
Allow the user to update a CD in the catalog.
removeFromCatalog
Allow the user to remove a CD from the catalog.
listByName
Allow the user to retrieve a list of CDs that match the given name.
listByArtist
Allow the user to retrieve a list of CDs that match the given artist name.
searchByCriteria
Allow the user to retrieve a list of CDs according to different parameters.

Java architecture

Our java example skeleton is divided into 4 packages :

cd.catalog.dao
The data access object is used to perform CRUD and more complex operations on data. It handles mapping objects and it's implementation depends on the underlying data storage engine : database (MySQL, HSQLDB, Oracle, ...), file system, memory, ...
cd.catalog.exception
This package contains Exception classes that can be raised by Services and Data access object implementations.
cd.catalog.mapping
This package contains low level beans used to map data from the data storage engine.
cd.catalog.service
The service classes perform the business logic and control the application functionalities. A service implementation depends on the way a service is accessed and on the desired service restriction : a delete functionality will only be available for a local administration tool and not for an exposed web service.

The Service interface, Dao interface and CD mapping object are defined bellow :

CD catalog class definition
Java class definition

Download the java library : CD catalog librairy