Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 3.3.5 generated on August 31 2005
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## kodo.enhance
Class JDOEnhancer

    java.lang.Object
      |
      +--kodo.enhance.JDOEnhancer

public class JDOEnhancer
extends 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.

Field Summary
`static int` | `ENHANCE_AWARE`
`static int` | `ENHANCE_NONE`
`static int` | `ENHANCE_PC`

Constructor Summary
`JDOEnhancer(JDOConfiguration conf, serp.bytecode.BCClass type, JDOMetaDataRepository repos)` Constructor.
`JDOEnhancer(JDOConfiguration conf, Class type)` Constructor.
`JDOEnhancer(JDOConfiguration conf, ClassMetaData type)` Constructor.

Method Summary
`int` | `enhance()` Perform bytecode enhancements.
`boolean` | `getAddDefaultConstructor()` A boolean indicating whether the enhancer should add a no-args constructor if one is not already present in the class.
`serp.bytecode.BCClass` | `getBytecode()` Return the bytecode representation of the class being enhanced.
`com.solarmetric.util.BytecodeWriter` | `getBytecodeWriter()` Return the current `BytecodeWriter` to write to or null if none.
`ClassMetaData` | `getClassMetaData()` Return the `ClassMetaData` object for this class, or null if not persistence capable.
`File` | `getDirectory()` The base build directory to generate code to.
`ClassMetaData` | `getMetaData()` Return the metadata for the class being enhanced.
`Class` | `getType()` Return the type being enhanced.
`boolean` | `isPersistenceCapable()` Return true if the class being enhanced is a `PersistenceCapable` type.
`static void` | `main(String[] args)` Usage: java kodo.enhance.JDOEnhancer [option]* <class name | .java file | .class file | .jdo file>+
`static boolean` | `run(JDOConfiguration conf, String[] args, JDOMetaDataRepository repos, File dir, ClassLoader loader, com.solarmetric.util.BytecodeWriter writer, boolean defCons, boolean tmpLoad)` Enhance the given class.
`static boolean` | `run(JDOConfiguration conf, String[] args, serp.util.Options opts)` Run the tool.
`void` | `setAddDefaultConstructor(boolean addDefaultConstructor)` A boolean indicating whether the enhancer should add a no-args constructor if one is not already present in the class.
`void` | `setBytecodeWriter(com.solarmetric.util.BytecodeWriter writer)` Set the `BytecodeWriter` to write the bytecode to or null if none.
`void` | `setDirectory(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`

Field Detail

### ENHANCE_NONE

    public static final int ENHANCE_NONE

### ENHANCE_AWARE

    public static final int ENHANCE_AWARE

### ENHANCE_PC

    public static final int ENHANCE_PC

Constructor Detail

### JDOEnhancer

    public JDOEnhancer(JDOConfiguration conf,
                       Class type)

  Constructor. Supply configuration and type to enhance.

### JDOEnhancer

    public JDOEnhancer(JDOConfiguration conf,
                       ClassMetaData type)

  Constructor. Supply configuration and type to enhance.

### JDOEnhancer

    public JDOEnhancer(JDOConfiguration conf,
                       serp.bytecode.BCClass type,
                       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

### getDirectory

    public File getDirectory()

  The base build directory to generate code to. The proper package structure will be created beneath this directory. Defaults to overwriting the existing class file if null.

### setDirectory

    public void setDirectory(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.

### getAddDefaultConstructor

    public boolean getAddDefaultConstructor()

  A boolean indicating whether the enhancer should add a no-args constructor if one is not already present in the class. The JDO specification requires that a no-arg constructor (whether created by the compiler or by the user) be present in a PC.

### setAddDefaultConstructor

    public void setAddDefaultConstructor(boolean addDefaultConstructor)

  A boolean indicating whether the enhancer should add a no-args constructor if one is not already present in the class. The JDO specification requires that a no-arg constructor (whether created by the compiler or by the user) be present in a PC.

### 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 Class getType()

  Return the type being enhanced.

### getMetaData

    public 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 ClassMetaData getClassMetaData()

  Return the `ClassMetaData` object for this class, or null if not persistence capable.

### getBytecodeWriter

    public com.solarmetric.util.BytecodeWriter getBytecodeWriter()

  Return the current `BytecodeWriter` to write to or null if none.

### setBytecodeWriter

    public void setBytecodeWriter(com.solarmetric.util.BytecodeWriter writer)

  Set the `BytecodeWriter` to write the bytecode to or null if none.

### enhance

    public int enhance()

  Perform bytecode enhancements.
  Returns:
    true if enhancement was performed, false otherwise

### writeBytecode

    public void writeBytecode()
                       throws IOException

  Write the generated bytecode.

### main

    public static void main(String[] args)
                     throws IOException

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

  Where the following options are recognized.

  - -properties/-p <properties file>: The path to a Kodo properties file containing information such as the license key, as outlined in `Configuration`; optional.
  - -<property name> <property value>: All bean properties of the standard Kodo `JDOConfiguration` can be set by using their names and supplying a value; for example: `-licenseKey adslfja83r3lkadf`
  - -directory/-d <build directory>: The path to the base directory where enhanced classes are stored. By default, the enhancer overwrites the original .class file with the enhanced version. Use this option to store the generated .class file in another directory. The package structure will be created beneath the given directory.

  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.

### run

    public static boolean run(JDOConfiguration conf,
                              String[] args,
                              serp.util.Options opts)
                       throws IOException

  Run the tool. Returns false if invalid options given.

### run

    public static boolean run(JDOConfiguration conf,
                              String[] args,
                              JDOMetaDataRepository repos,
                              File dir,
                              ClassLoader loader,
                              com.solarmetric.util.BytecodeWriter writer,
                              boolean defCons,
                              boolean tmpLoad)
                       throws 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
    `defCons` - indicates whether or not to add a no-args constructor to a PC if one is not present
    `tmpLoad` - indicates whether or not to use a temporary class loader
  Returns:
    false if invalid option given
  Throws:
    `IOException` - if unable to save enhanced bytecode

Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 3.3.5 generated on August 31 2005
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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