Chapter 5. Sample Architecture
Prev | Part V. Kodo J2EE Tutorial | Next

## Chapter 5. Sample Architecture

The application is a simple enterprise application that demonstrates some of the basic concepts necessary when using Kodo in the enterprise layer.

The core model wraps a Stateless SessionBean facade around a PersistenceCapable instance. Using a SessionBean provides both a remote interface for various clients as well as providing a transactional context in which to work (and thus avoiding any explicit transactional code).

This SessionBean uses the Data Transfer Object pattern to provide the primary communication between the application server and the (remote) client. The Car instance will be used as the primary object upon which the client will work.

This model can be easily adapted to using EntityBeans. See our sample ejb directory and `JDOEntityBean` for more details on how to using JDO to power your EntityBean.

- `samples/j2ee/Car.java`: The core of the sample application. This is the `PersistenceCapable` class that Kodo will use to persist the application data. Instances of this class will also fill the role of data transfer object (DTO) for EJB clients. To accomplish this need, Car implements `java.io.Serializable` so that remote clients can access these as parameters and return values from the EJB.

- `samples/j2ee/package.jdo`: The JDO metadata file for the package. Note that some appservers have a problem with the way we include an internal DTD. If you see a lot of illegal/malformed character exceptions, uncomment out the DTD declaration in this file.

- `samples/j2ee/SampleUtilities.java`: This is a simple facade to aggregate some core JDO functionality into some static methods. By placing all of the functionality into a single facade class, we can reduce code maintenance, as well as having the added advantage of being able to access Kodo JDO from other portions of the application such as a servlet or JSP (though this functionality is not demonstrated in this sample). In addition, some simple utility functions such as JNDI helper methods are also in this class.

- `samples/j2ee/ejb/Car*.java`: The source for the CarEJB Session Bean. Clients can use the `CarHome` and `CarRemote` interfaces to find, manipulate, and persist changes to `Car` transfer object instances. By using J2EE transactional features, the implementation code in CarBean.java can be focused almost entirely upon business and persistence logic without worrying about transactions.

- `samples/j2ee/jsp/*.jsp`: The web presentation client. They are JDO agnostic, and use the CarEJB Session Bean and the Car transfer object to do all the work.

- `samples/j2ee/resources/*`: Files required to deploy to the various appservers, including J2EE deployment descriptors, WAR/ EJB/ EAR descriptors, as well as appserver specific files.

- `samples/j2ee/build.xml`: A simple Ant build file to help in creating a J2EE EAR file.

- `samples/j2ee/samples.properties`: A simple .properties file to tailor the sample application to your particular appserver and installation

Prev | Up | Next
Chapter 4. Using The Sample Application | Home | Chapter 6. Code Notes and J2EE Tips