11. Generating a Schema from Java Classes


The mapping tool can jump start development by generating Package, Class, and Attribute schema objects from existing Java classes. The classes must be compiled into byte code, it is not possible to generate a mapping schema from Java source code.

To utilize this option select the Generate->Schema from Java classes menu option to display the dialog box shown below.

mtgenschclassdlg.jpg (39983 bytes)

If the classes belong to a Java package, you must enter, or select from the combo box drop down list, the package name that the classes belong to. If the classes do not belong to a package, you must enter the name of the directory where the classes reside. Once you specify either one, click the List Available Classes button to display the classes found in the Available list. If you specified a package name, the mapping tool will search for the directory where the classes reside using the system's CLASSPATH. If the directory is found, the directory name will also be displayed in the Directory text field. If the directory is not found, make sure that the classes are located in a directory structure as expected by the class loader and under a parent directory specified in the system's CLASSPATH.

The Available list will show both abstract and concrete classes, but will exclude interfaces. Use the Add and Add All buttons to move classes from the Available list to the Selected list. You can also use the Remove and Remove All buttons to move classes from the Selected list back to the Available list.

Click the Options button to bring up the Java Type Mappings panel of the configuration dialog box if necessary to verify or update any relevant settings.

Once the Selected list displays the classes for which you want to generate schema objects click the Generate button to start the generation process. The generation procedure creates a Package schema object with the supplied package name, if one does not already exist, and then adds Class schema objects for each selected class, including abstract classes, to the Package object. Attribute schema objects are created for each member variable and added to their corresponding Class schema objects. Attribute objects will not be generated for member variables declared with the static, final, or transient modifiers. The attribute objects of a superclass are not duplicated in each of its subclasses. The status bar at the bottom edge of the mapping tool will inform you when the generation process has completed.

The generated schema objects do not overwrite any existing schema objects, instead they are added to the tree. This means you can run this procedure multiple times against multiple packages without overwriting any previous schema objects. If you do want to clear out any existing schema objects use the File->New Schema menu option before running this procedure.

 

Next Section

Return to Table of Contents