Skip navigation links

ACAF Address Book Sample

The "Address Book" application is a sample base application, used to demonstrate the usage of "A Common Application Framework" (ACAF).

See: Description

Package Description
This package contains the business classes of the address book application.
This package contains the message catalog classes used to internationalize the address book application.
This package contains several database facades, used to store and retrieve the business objects of the address book application in/from a relational database.
This package contains the JUnit tests of the address book application.
This package contains an XML facade, used to serialize and deserialize the business objects of the addess book application into/from a XML file.

The "Address Book" application is a sample base application, used to demonstrate the usage of "A Common Application Framework" (ACAF).

Download and Installation

The ZIP archive containing the sample application can be downloaded from the following site:

The installation is very simple, just unzip the downloaded ZIP archive. This creates the following directory structure:

When you intend to run the message compiler ANT script, you have to adjust the location properties MESSAGECOMPILERHOME and ContactsDevRoot in the script file.

ACAF Address Book - A Sample Application

The address book application is a very simple application, showing the basic concepts of ACAF. This is not a ready to use application with a GUI and it is not intended to be used in a productive environment. However the structure and the classes can be used as template to start developing your application with ACAF. You may also have a look at the more advanced sample competition management application.

Business Classes

The package de.tmasoft.acaf.sample.contacts.businessclasses contains the business classes of the application, which are build with the component, attribute and container classes of ACAF. The class AddressBook is the root business class of the business class composite , which contains Person business objects in its contacts container. Persons contain business objects of the classes Address and PhoneNumber in the containers addresses and phoneNumbers. All business classes are derived from the base class BaseComponent. This base class defines the abstract method BaseComponent.acceptBusinessVisitor(BusinessVisitor), which has to be implemented by the concrete business classes to accept a business visitor. A sample how such a business visitor may be used can be found in the class AddressBook, where the inner class SearchVisitor extends the BusinessVisitor to search persons in the address book via the method AddressBook.findContacts(String).


The package de.tmasoft.acaf.sample.contacts.msgcat contains the message files ContactsMessageTable.msg and ContactsTextTable.msg, where the localized error messages and texts of the address book application are defined. These files are translated by the Message Compiler to create the property resource files and the enumerations ContactsMessageTable and ContactsTextTable with the keys to access the messages. The files contain the texts in English and German. The ANT script ContactsMsgCatAntScript.xml, which can be found in the scripts directory, can be used to compile the message files. Before you can use the ANT script you have to adjust some location properties to the directory paths of your programming environment. This ANT script creates also the following HTML documentation files for the error messages:

The singleton classes ContactsMessageCatalog and ContactsTextCatalog are used to access the localized texts in the resource files. These catalog classes are used to initialize the component base class, the attributes and the enumeration values to get the display type, display keyword and the string representation of the enumeration values.

Database Persistence

The package de.tmasoft.acaf.sample.contacts.persistence contains several database facades to store and retrieve the business objects in a relational database. The scripts directory contains the SQL script CreateAddressBookMySqlDB.sql, which can be used to create the database tables for the address book application in a MySQL database. The database access facades are all implemented as singleton and must be initialized with a database Connection or a DataSource. The SimpleDatabaseFacade uses updatable result sets to store the business objects in the database. Each store and update method performs the operation inside a transaction. So this facade provides a very simple to use interface. The DatabaseFacade works similar to the simple database facade, but it provides public methods to control transactions. So users can perform several update or store operations in a transaction. The StatementDatabaseFacade is a sample how to store and delete business objects with explicit SQL INSERT, UPDATE and DELETE statements.

XML Serialization

The package de.tmasoft.acaf.sample.contacts.xml contains the XmlFacade, which can be used to store and retrieve the business objects in/from a XML file. This facade class shows how attribute value converters are used to convert values of date and enumeration attributes to XML compliant values.

JUnit Tests

The package de.tmasoft.acaf.sample.contacts.test contains the JUnit tests of the address book application. Before you can run the tests you have to adjust the constants, which specify the parameters to create the database connection, which are the JDBC driver class name, the database URL, user name and password. The unit test methods show, how business objects can be created with commands and how to store and retrieve the address book using the different database facades and the XML facade.

Thomas Mayr, TMASoft
Skip navigation links