Examining a JDO Implementation


The persistence manager factory has two methods that reveal information about the JDO implementation. One of these methods identifies the optional JDO features that the implementation supports, and the other identifies the implementation's vendor and version.

Determining the Implementation's Support for Optional Features

JDO defines many optional features that a JDO implementation may, or may not, support. To determine whether an implementation supports an optional feature, the application calls the supportedOptions method in the PersistenceManagerFactory interface.

 public java.util.Collection supportedOptions() 

The supportedOptions method returns a Collection of strings, one string for each optional feature that the implementation supports. The collection may also include vendor-defined strings that identify features added to the implementation by the vendor. Depending on the number of optional features that the implementation supports, the returned collection can vary in length from 2 to more than 20 strings.

Table 6-1 identifies each string value specified by JDO and briefly describes the corresponding implementation option that is supported when the string is returned.

Table 6-1: Identifying Strings for the Supported Implementation Options

Property Name

Indicates Support For

javax.jdo.query.JDOQL

JDO's query language (required).

javax.jdo.option.ApplicationIdentity

Application JDO identity.

javax.jdo.option.DatastoreIdentity

Datastore JDO identity.

javax.jdo.option.NonDurableIdentity

Nondurable JDO identity.

javax.jdo.option.TransientTransactional

Transient-clean and transient-dirty JDO states.

javax.jdo.option.NontransactionalRead

Transaction's NontransactionalRead property can be set to true.

javax.jdo.option.NontransactionalWrite

Transaction's NontransactionalWrite property can be set to true.

javax.jdo.option.RetainValues

Transaction's RetainValues property can be set to true.

javax.jdo.option.Optimistic

Transaction's Optimistic property can be set to true.

javax.jdo.option.ArrayList

Persistent fields that refer to ArrayList types.

javax.jdo.option.HashMap

Persistent fields that refer to HashMap types.

javax.jdo.option.Hashtable

Persistent fields that refer to Hashtable types.

javax.jdo.option.LinkedList

Persistent fields that refer to LinkList types.

javax.jdo.option.TreeMap

Persistent fields that refer to TreeMap types.

javax.jdo.option.TreeSet

Persistent fields that refer to TreeSet types.

javax.jdo.option.Vector

Persistent fields that refer to Vector types.

javax.jdo.option.Map

Persistent fields that refer to Map types.

javax.jdo.option.List

Persistent fields that refer to List types.

javax.jdo.option.Array

Persistent fields that refer to array types.

javax.jdo.option.NullCollection

Null values permitted in persistent fields that refer to collections.

javax.jdo.option.ChangeApplicationIdentity

Values of application-defined key fields can be changed in persistent application data objects.

As the table indicates, the first option javax.jdo.option.JDOQL is not really an option at all. Every implementation should place this string in the collection returned from the supportedOptions method. If the implementation supports another query language or API, it may include an additional property string that it defines in the collection of strings. At least one of the next two options, javax.jdo.option.ApplicationIdentity or javax.jdo.option.DatastoreIdentity, should also be found in the collection returned. The rest of the JDO options may, or may not, be implemented by a specific vendor.

To be portable, an application should rely on as few options as possible. Some options, such as the ability to turn on optimistic transactions or use datastore identity, are very useful.

Obtaining Vendor-Specific Information from the Implementation

The getProperties method provides information about the implementation that is vendor specific.

 public java.util.Properties getProperties() 

The getProperties method returns a set of read-only properties that identify the implementation and may provide vendor-specific information about the implementation. Each property is a key-value pair of strings. JDO defines only two keys for these properties, VendorName and VersionNumber. The implementation defines any other keys that are used. Although the application can modify these properties, the JDO implementation ignores any modifications.




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