The management of Type information in JPOX revolves around a TypeManager. This acts as a registry of type support, as shown in the diagram below.
The internal structure of JPOX allows for simple addition of new SCO types. The TypeManager class is a singleton class and has an addType method to allow addition of new type support. You then specify the type, whether it is part of the default-fetch-group, the mapping type for the SCO support, and the wrapper type for mutable SCO support. The SCO mapping type should extend org.jpox.store.mapping.Mapping, whilst the mutable SCO wrapper should implement org.jpox.sco.SCO. The Mapping class allows the mapping between a class field and several columns in a table in the datastore. The majority of types map one-to-one with a column, however the structure is flexible enough to allow mapping to multiple. In addition to the TypeManager, each DatabaseAdapter can override the SCO mapping type with their own preferred mapping type. This is done because some databases support only particular types, and so sometimes need to have something tailored to their own definition. This is set up in the "typeMappings" attribute of DatabaseAdapter. The Second-Class wrapper types for mutable SCO's typically extend the type that they represent, adding wrappers to the mutator methods so that they can intercept these calls and update the data store directly. The Second-Class support for Collection-based entities utilise backing store classes. Examples can be seen within the org.jpox.store.setstore, org.jpox.store.liststore, and org.jpox.store.mapstore packages.
We plan to extend the JPOX implementation in the future to allow addition of Type "plugins", so that users can supply JAR's supporting their own types, allowing flexible extension rather than wait for the support for a Type to be added officially to JPOX. It is envisaged that this can be for SCO support of types, providing a standardised interface (org.jpox.store.mapping.Mapping for SCO mappings and org.jpox.sco.SCO for SCO mutable wrappers) to write to. |