Chapter 1. The Pet Shop

Table of Contents

1.1. Included Files
1.2. Important Utilities

Imagine that you have decided to create a software toolkit to be used by pet shop operators. This toolkit must provide a number of solutions to common problems encountered at pet shops. Industry analysts indicate that the three most desired features are inventory maintenance, inventory growth simulation, and behavioral analysis. Not one to question the sage advice of experts, you choose to attack these three problems first.

According to the aforementioned experts, most pet shops focus on three types of animals only: dogs, rabbits, and snakes. This ontology suggests the following class hierarchy:

Class Hierarchy

                        Animal
                          ^
                          |
                +--------------------+
                |         |          |
               Dog      Rabbit     Snake
        	

1.1. Included Files

We have provided an implementation of Animal and Dog classes, plus some helper classes and files to create the initial schema and populate the database with some sample dogs. Let's take a closer look at these classes.

  • tutorial.JDOFactory provides access to a properly configured javax.jdo.PersistenceManagerFactory.

    The PersistenceManagerFactory class is the main entry point into the JDO framework. PersistenceManagerFactories provide a mechanism for obtaining individual PersistenceManager instances, through which a user can find objects in the underlying data store. See the javax.jdo javadoc for a more in-depth discussion of JDO in general and the PersistenceManagerFactory class in particular.

  • tutorial.AnimalMaintenance provides some utility methods for examining and manipulating the animals stored in the database. We will fill in method definitions in Chapter III.

  • tutorial.Animal is the superclass of all animals that this pet store software can handle.

  • tutorial.Dog contains data and methods specific to dogs.

  • tutorial.Rabbit contains data and methods specific to rabbits. It will be used in Chapter IV of this tutorial.

  • tutorial.Snake contains data and methods specific to snakes. It will be used in Chapter V of this tutorial.

  • tutorial.jdo is a JDO metadata file that defines which types should be enhanced into persistence-capable or persistence-aware classes. For more information on JDO metadata, consult the metadata section of the JDO Overview.

  • kodo.properties is a properties file containing Kodo-specific and standard JDO configuration settings.

    Important

    You must specify a valid Kodo license key in the kodo.properties file.

  • solutions contains the complete solutions to this tutorial, including finished versions of the .java files listed above and a correct tutorial.jdo metadata file.