Chapter 5: Enhanced Classes and Managed Fields


The application programmer designs and codes the application data classes. The JDO implementation provides an enhancer tool to modify the application data classes. The modifications made during enhancement allow JDO and the application data objects to interact with each other. The JDO metadata, which is contained in an XML file, identifies the application data classes and describes their managed fields.

To begin, this chapter describes, in a general way, what application data classes are. It details JDO's requirements for their managed and unmanaged fields and how enhancement changes the application data class. It concludes by describing the tags and attributes of the JDO metadata.

Which Application Classes Should Be Enhanced?

Application data classes represent fine-grained objects that model the interesting state of the real world. The application data classes and their interrelationships may be simple or complex, depending on the needs of the application. Application data classes may inherit from classes that will be enhanced or from classes that will not be enhanced. Application data classes may implement interfaces. There may be only a few application data classes, or there may be hundreds.

An application data class may be code light or it may be code heavy. It may have only getter-setter methods to control access to member fields, enforce rules for valid state, and handle type conversions. Although it often makes sense to keep application data classes light in code, JDO handles code-intensive application data classes equally well. Application designers can put into the application data classes as much code as they need.

JDO assumes that application data classes hold their persistent state in their instance fields. If the persistent state is someplace else, such as in a system resource outside the JVM, then JDO cannot manage the object's persistent state. For example, JDO cannot make the java.io.FileInputStream class persistence capable because most of its interesting state is in a file rather than in the class's member variables.

The application data classes define the application's persistent object model. Designing the persistent object model for most applications is a nontrivial task. The designer must identify the classes of persistent objects, the elements of their persistent state, the relationships between the objects, the behavior of the objects, their collaboration with other objects, the inheritance relationships between classes, and so forth. JDO helps the designer carry out these tasks by staying out of the way.

From a designer's standpoint, the ideal persistence service is orthogonal to all other concerns in the object model. For this reason, JDO strives not to impose constraints on the persistent object model. JDO goes a long way towards this ideal because, for the most part, the application programmer can design and code the application data classes without being aware of JDO.




Using and Understanding Java Data Objects
Using and Understanding Java Data Objects
ISBN: 1590590430
EAN: 2147483647
Year: 2005
Pages: 156
Authors: David Ezzio

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net