JPOX
JPOX
 Project  |  Ver 1.1  |  Ver 1.2  |  JDO  |  JPA  |  Guides  |  Tools
1.1 | Preparation | O/R Mapping | Runtime | Extensions | Developer
Development
Testing
JPOX Design : MetaData

JPOX manages MetaData using the org.jpox.metadata package. This provides a mixture of immutable data objects (FileMetaData, PackageMetaData, ClassMetaData, FieldMetaData, ColumnMetaData, CollectionMetaData, MapMetaData, ArrayMetaData) and controlling objects (MetaDataManager, MetaDataParser) responsible for loading and managing the metadata. These are discussed below.

MetaDataManager

The process within the JPOX core is started by a request for Meta-Data from the MetaDataManager. Each PersistenceManagerFactory has a manager for its Meta-Data, and all requests go through that manager. When the Meta-Data is requested for a class the manager follows the following steps

  1. Check the cache of classes known NOT to have Meta-Data. If present, it just returns null.
  2. Checks its cache of MetaData files for the package and class required returning it as appropriate.
  3. Checks the locations for a JDO Meta-Data file containing the requested class. If one is found, it is loaded (all classes in the file, not just the specified class). The Meta-Data for the file is then cached and the classes Meta-Data returned.
  4. If no Meta-Data is found then the class is added to the cache of classes known NOT to have Meta-Data (to save any future lookup searches).
MetaDataParser

When the MetaDataManager has a filename and needs to parse the file it calls the MetaDataParser. This has the sole purpose of taking a filename URL and returning a FileMetaData object representing that file. This uses an XML parser to parse the elements of the JDO Meta-Data file and generate objects of FileMetaData, PackageMetaData, ClassMetaData, etc as it encounters the elements in the file. It parses using the JDO 2.0 (draft) specification of Meta-Data.

This is also used by the JPOX enhancer in parsing the Meta-Data files in preparation for enhancing the classes using the specification found in the file.

MetaData Components

The Meta-Data component classes are arranged in a tree hierarchy (just as they are in the Meta-Data file). The top level is FileMetaData which stores the file name and has a collection of PackageMetaData. Each PackageMetaData has a name and a set of ClassMetaData. And so on. As the JDO Meta-Data specification is extended, classes are added here to model each element in the XML file.

MetaDataUtils

The only other class that should be mentioned is MetaDataUtils which provides a series of utilities to aid the process of handling MetaData in JPOX. The most significant part are methods to check the possible JDO file locations for a file holding Meta-Data for a particular class, returning the filename that contains the classes Meta-Data. This is used by the MetaDataManager when looking up the Meta-Data for a class.

MetaData and the JPOX process

JPOX represents the Meta-Data JDO files specified for classes internally with the class (and subclasses) MetaData. MetaData is extended for the particular cases of classes (ClassMetaData), fields (FieldMetaData), collections (CollectionMetaData), and maps (MapMetaData). Each of these classes contains features specific to that component. When a class is identified to the JPOX system, a JDO MetaData file is searched for for that class, and the internal MetaData representation is loaded. This is cached throughout the lifetime of the application (since, with JDO 1.0 at least, MetaData is static).

Please refer to this diagram highlighting the process of MetaData handling in JPOX