SolarMetric Kodo JDO 2.5.0 Reverse Schema Tool

com.solarmetric.rd.kodo.enhance
Class JDOEnhancer

java.lang.Object
  |
  +--com.solarmetric.rd.kodo.enhance.JDOEnhancer

public class JDOEnhancer
extends java.lang.Object

Bytecode enhancer used to create PersistenceCapable classes from JDO metadata. The bytecode modifications made by this enhancer are consistent with the description of the reference enhancer in the JDO 1.0 Specification.

The enhancer must be invoked on all persistence-capable and persistence aware classes before running any application that uses JDO. Additionally, before the enhancer can be invoked, JDO metadata must be available for all persistence-capable types.


Constructor Summary
JDOEnhancer(com.solarmetric.rd.kodo.conf.JDOConfiguration conf, serp.bytecode.BCClass type, com.solarmetric.rd.kodo.meta.JDOMetaDataRepository repos)
          Constructor.
JDOEnhancer(com.solarmetric.rd.kodo.conf.JDOConfiguration conf, java.lang.Class type)
          Constructor.
JDOEnhancer(com.solarmetric.rd.kodo.conf.JDOConfiguration conf, com.solarmetric.rd.kodo.meta.ClassMetaData type)
          Constructor.
 
Method Summary
 boolean enhance()
          Perform bytecode enhancements.
 serp.bytecode.BCClass getBytecode()
          Return the bytecode representation of the class being enhanced.
 com.solarmetric.rd.kodo.meta.ClassMetaData getClassMetaData()
          Return the ClassMetaData object for this class, or null if not persistence capable.
 java.io.File getCodeDirectory()
          The base build directory to generate code to.
 com.solarmetric.rd.kodo.meta.ClassMetaData getMetaData()
          Return the metadata for the class being enhanced.
 java.lang.Class getType()
          Return the type being enhanced.
 boolean isPersistenceCapable()
          Return true if the class being enhanced is a PersistenceCapable type.
static void main(java.lang.String[] args)
          Usage: java com.solarmetric.kodo.enhance.JDOEnhancer [option]* <class name | .java file | .class file | .jdo file>+
static boolean run(com.solarmetric.rd.kodo.conf.JDOConfiguration conf, java.lang.String[] args, com.solarmetric.rd.kodo.meta.JDOMetaDataRepository repos, java.io.File dir, java.lang.ClassLoader loader)
          Enhance the given class.
 void setCodeDirectory(java.io.File dir)
          The base build directory to generate code to.
 void writeBytecode()
          Write the generated bytecode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDOEnhancer

public JDOEnhancer(com.solarmetric.rd.kodo.conf.JDOConfiguration conf,
                   java.lang.Class type)
Constructor. Supply configuration and type to enhance.


JDOEnhancer

public JDOEnhancer(com.solarmetric.rd.kodo.conf.JDOConfiguration conf,
                   com.solarmetric.rd.kodo.meta.ClassMetaData type)
Constructor. Supply configuration and type to enhance.


JDOEnhancer

public JDOEnhancer(com.solarmetric.rd.kodo.conf.JDOConfiguration conf,
                   serp.bytecode.BCClass type,
                   com.solarmetric.rd.kodo.meta.JDOMetaDataRepository repos)
Constructor. Supply configuration.

Parameters:
type - the bytecode representation fo the type to enhance; this can be created from any stream or file
repos - A metadata repository to use for metadata access, or null to create a new reporitory; the repository from the given configuration isn't used by default because the configuration might be an implementation-specific subclass whose metadata required more than just base JDO metadata files
Method Detail

getCodeDirectory

public java.io.File getCodeDirectory()
The base build directory to generate code to. The proper package structure will be creaed beneath this directory. Defaults to overwriting the existing class file if null.


setCodeDirectory

public void setCodeDirectory(java.io.File dir)
The base build directory to generate code to. The proper package structure will be creaed beneath this directory. Defaults to overwriting the existing class file if null.


getBytecode

public serp.bytecode.BCClass getBytecode()
Return the bytecode representation of the class being enhanced. The returned bytecode can be written to any file or stream.


getType

public java.lang.Class getType()
Return the type being enhanced.


getMetaData

public com.solarmetric.rd.kodo.meta.ClassMetaData getMetaData()
Return the metadata for the class being enhanced.


isPersistenceCapable

public boolean isPersistenceCapable()
Return true if the class being enhanced is a PersistenceCapable type.


getClassMetaData

public com.solarmetric.rd.kodo.meta.ClassMetaData getClassMetaData()
Return the ClassMetaData object for this class, or null if not persistence capable.


enhance

public boolean enhance()
Perform bytecode enhancements.

Returns:
true if enhancement was performed, false otherwise

writeBytecode

public void writeBytecode()
                   throws java.io.IOException
Write the generated bytecode.

java.io.IOException

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException

Usage: java com.solarmetric.kodo.enhance.JDOEnhancer [option]* <class name | .java file | .class file | .jdo file>+

Where the following options are recognized.

Each additional argument can be either the full class name of the type to enhance, the path to the .java file for the type, the path to the .class file for the type, or the path to a .jdo file listing one or more types to enhance. If the type being enhanced has JDO metadata, it will be enhanced as a persistence capable class. If not, it will be considered a persistence aware class, and all access to fields of persistence capable classes will be replaced by the appropriate get/set method. If the type explicitly declares the PersistenceCapable interface, it will not be enhanced. Thus, it is safe to invoke the enhancer on classes that are already enhanced.

java.io.IOException

run

public static boolean run(com.solarmetric.rd.kodo.conf.JDOConfiguration conf,
                          java.lang.String[] args,
                          com.solarmetric.rd.kodo.meta.JDOMetaDataRepository repos,
                          java.io.File dir,
                          java.lang.ClassLoader loader)
                   throws java.io.IOException
Enhance the given class.

Parameters:
conf - configuration containing license key information, logging information, etc.
args - the arguments to parse for classes to enhance
repos - a metadata repository to use for metadata access, or null to create a new repository; the repository from the given configuration isn't used by default because the configuration might be an implementation-specific subclass whose function requires more than just base JDO metadata files
dir - the output directory, or null to overwrite original class file
Returns:
false if invalid option given
Throws:
java.io.IOException - if unable to save enhanced bytecode

SolarMetric Kodo JDO 2.5.0 Reverse Schema Tool

Copyright 2001,2002,2003 SolarMetric, Inc. All Rights Reserved.