Show TOC Start of Content Area

Process documentation JDO Enhancement  Locate the document in its SAP Library structure

Purpose

The JDO Enhancer does bytecode modifications on Java classes to make them persistence capable prior to loading them in the runtime. During the process of enhancement, the implementation of the javax.jdo.PersistenceCapable interface is added to the classes.

The automatic class enhancement is a convenient way of creating a JDO-aware application without having to implement the PersistenceCapable interface and all its methods manually. All you have to do is to provide the compiled Java classes and the JDO metadata.

Process Flow

The enhancement process is transparent to the application. The JDO enhancer is run before the application classes are loaded in the JVM (graphic 1).

This graphic is explained in the accompanying text

Graphic 1: JDO Enhancement Process

The JDO enhancer applies changes to the classes to make them persistence capable. Among these changes are the following:

·        Adding “implements PersistenceCapable” to the class definition;

·        Appending the implementations of the methods from the PersistenceCapable interface;

·        Adding accessor and mutator methods for the managed fields in the class;

·        Declaring additional specific fields required for the classes that implement the interface – for example, a jdoStateManager field is added in the topmost class of the class hierarchy to establish the relation with the StateManager, which manages the values of the persistent fields and the life cycle of the persistent instances.

·        Direct accesses to persistent fields are replaced by method calls, and so on.

On the basis of the information from the JDO metadata, the JDO Enhancer defines which fields are to be persistent. By default, all fields that are not declared final, static, or transient in the Java class become persistent, unless they are defined non-persistent in the metadata. For more information about field modifiers, see JDO Metadata.

To start the JDO Enhancer, you have to run its main class. The com.sap.jdo.enhancer.Main class is the implementation class of the JDO Enhancer. It is used as follows:

java com.sap.jdo.enhancer.Main <options> <jdofile> <classfile>

You can also use the following parameters:

JDO Enhancer Options

Option

Description

-h, --help

Prints usage message and exits

-v, --verbose

Prints verbose messages

-q, --quiet

Supresses warnings

-s, --sourcepath

Source path for JDO and class files

-d, --destdir <dir>

Destination directory for output files

-f, --force

Overwrites output files

-n, --nowrite

Never writes output files

-t, --timing

Measures timing

 

In addition, you can use the JDO Checker – a tool that checks the consistency of the classes to be enhanced.

The com.sap.jdo.sql.util.JDO class is the implementation of the JDO Checker. It is used as follows:

java com.sap.jdo.sql.util.JDO <options> <command> (<classfile>...|<class>...| tables <table>...)

JDO Checker Options

Option

Description

-h

Prints usage message and exits

-v

Prints verbose messages

-p

Property file

-c

Catalog path

 

JDO Checker Commands

Syntax

CHECK <classfile>

Arguments

 

<classfile>

The name of the file to be checked

Description

Checks mapping.

 

Catalog/Checker Properties

Property

Value

com.sap.jdo.sql.mapping.checkCatalog

TRUE

com.sap.jdo.sql.mapping.checkConsistency

TRUE

com.sap.jdo.sql.mapping.checkConsistencyDeep

TRUE

 

See also:

Running the JDO Enhancer and Checker Tools

 

 

End of Content Area