Package javax.jdo

Class Enhancer

java.lang.Object
javax.jdo.Enhancer

public class Enhancer extends Object
Main class to invoke a JDO Enhancer. The enhancer is invoked with the following command line:
 java -cp {classpath} javax.jdo.Enhancer {options} {directory, file, or resource names}
 
<classpath> must contain the jdo specification jar, the implementation jar and any implementation dependencies, the statically-compiled classes, and the jdo metadata files loadable as resources. <options> include:
  • ? : print usage to stderr and exit
  • -h : print usage to stderr and exit
  • -help : print usage to stderr and exit
  • -pu <persistence-unit-name> : the name of a persistence unit
  • -d <target directory> : write the enhanced classes to the specified directory
  • -checkonly : just check the classes for enhancement status
  • -v : verbose output
  • -r : recurse through directories to find all classes and metadata files to enhance
  • -cp <enhancer class loader path> : if not already included in the java class loader, this parameter must contain the statically-compiled classes, and the jdo metadata files loadable as resources
<directory, file, or resource names>
  • Directory names must not end in ".jdo", ".jar", or ".class"
  • Directories will be searched for files with suffixes ".jdo", ".jar", and ".class"
  • Directories will be searched recursively if the -r option is set
Since:
3.0
  • Field Details

    • msg

      private static final I18NHelper msg
      The Internationalization message helper.
    • NL

      private char NL
      New Line
    • JAR_FILE_SUFFIX

      private String JAR_FILE_SUFFIX
      Jar file suffix
    • JDO_FILE_SUFFIX

      private String JDO_FILE_SUFFIX
      JDO Metadata file suffix
    • CLASS_FILE_SUFFIX

      private String CLASS_FILE_SUFFIX
      Class file suffix
    • error

      private boolean error
      Error indicator
    • printAndExit

      private boolean printAndExit
      If set, process parameters, print usage, and exit.
    • persistenceUnitNames

      private List<String> persistenceUnitNames
      Persistence Units
    • directoryName

      private String directoryName
      Target Directory Parameter
    • loader

      private ClassLoader loader
      ClassLoader for JDOEnhancer
    • classPath

      private String classPath
      Classpath (-cp) parameter
    • checkOnly

      private boolean checkOnly
      Check Only flag
    • verbose

      private boolean verbose
      Verbose flag
    • recurse

      private boolean recurse
      Recurse flag
    • errorBuffer

      private StringBuilder errorBuffer
      Error messages should be empty unless there is an error
    • verboseBuffer

      private StringBuilder verboseBuffer
      Verbose messages are always collected but only output if verbose flag is set
    • fileNames

      private List<String> fileNames
      File Names
    • classFileNames

      private List<String> classFileNames
      Class File Names
    • jdoFileNames

      private List<String> jdoFileNames
      JDO File Names
    • jarFileNames

      private List<String> jarFileNames
      Jar File Names
    • numberOfValidatedClasses

      private int numberOfValidatedClasses
      The number of classes validated by the JDOEnhancer
    • numberOfEnhancedClasses

      private int numberOfEnhancedClasses
      The number of classes enhanced by the JDOEnhancer
    • properties

      private Properties properties
      The properties from the JDOEnhancer
  • Constructor Details

    • Enhancer

      public Enhancer()
  • Method Details

    • main

      public static void main(String[] args)
      Run the enhancer from the command line.
      Parameters:
      args - command line arguments
    • run

      private void run(String[] args)
      Execute the enhancer.
      Parameters:
      args - the command line arguments
    • processArgs

      private void processArgs(String[] args)
      Process the command line arguments and exit if there is a usage request or an error.
      Parameters:
      args - the command line arguments
    • parseArgs

      private void parseArgs(String[] args)
      Parse the command line arguments. Put the results into fields.
      Parameters:
      args - the command line arguments
    • hasNextArgument

      private boolean hasNextArgument(String msgId, String where, int i, int length)
      Check whether there is another parameter (the argument for an option that requires an argument).
      Parameters:
      msgId - the message id for an error message
      where - the parameter for the message
      i - the index into the parameter array
      length - the length of the parameter array
      Returns:
    • parseFiles

      private void parseFiles(String[] fileNames, boolean search, boolean recurse)
      Files can be one of four types:
      1. directory: the directory is examined for files of the following types
      2. .class: this is a java class file
      3. .jdo: this is a jdo metadata file
      4. .jar: this is a jar file
      If the recursion flag is set, directories contained in directories are examined, recursively.
    • prepareClassLoader

      private ClassLoader prepareClassLoader(String classPath)
      Prepare the class loader from the classPath specified
      Parameters:
      classPath - the classPath string from the "-cp classPath" option
      Returns:
      the class loader
    • addErrorMessage

      private void addErrorMessage(String message)
      Add a message to stderr.
      Parameters:
      message - the internationalized message to add
    • setError

      private void setError()
      Set the error flag.
    • setPrintAndExit

      private void setPrintAndExit()
      Set the print-and-exit flag.
    • exit

      private void exit(int exitValue)
      Exit this process.
      Parameters:
      exitValue - the process exit value
    • addVerboseMessage

      private void addVerboseMessage(String msgId, String... where)
      Add a message to the verbose message buffer.
      Parameters:
      msgId - the message id
      where - the parameter
    • addVerboseMessage

      private void addVerboseMessage(String msgId, String where)
      Add a message to the verbose message buffer.
      Parameters:
      msgId - the message id
      where - the parameter
    • addVerboseMessage

      private void addVerboseMessage(String msgId)
      Add a message to the verbose message buffer.
      Parameters:
      msgId - the message id
    • addVerboseMessage

      private void addVerboseMessage(String msgId, int where)
      Add a message to the verbose message buffer.
      Parameters:
      msgId - the message id
      where - the parameter