Class Enhancer
java.lang.Object
javax.jdo.Enhancer
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 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 Summary
FieldsModifier and TypeFieldDescriptionprivate booleanCheck Only flagprivate StringClass file suffixClass File Namesprivate StringClasspath (-cp) parameterprivate StringTarget Directory Parameterprivate booleanError indicatorprivate StringBuilderError messages should be empty unless there is an errorFile Namesprivate StringJar file suffixJar File Namesprivate StringJDO Metadata file suffixJDO File Namesprivate ClassLoaderClassLoader for JDOEnhancerprivate static final I18NHelperThe Internationalization message helper.private charNew Lineprivate intThe number of classes enhanced by the JDOEnhancerprivate intThe number of classes validated by the JDOEnhancerPersistence Unitsprivate booleanIf set, process parameters, print usage, and exit.private PropertiesThe properties from the JDOEnhancerprivate booleanRecurse flagprivate booleanVerbose flagprivate StringBuilderVerbose messages are always collected but only output if verbose flag is set -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddErrorMessage(String message) Add a message to stderr.private voidaddVerboseMessage(String msgId) Add a message to the verbose message buffer.private voidaddVerboseMessage(String msgId, int where) Add a message to the verbose message buffer.private voidaddVerboseMessage(String msgId, String where) Add a message to the verbose message buffer.private voidaddVerboseMessage(String msgId, String... where) Add a message to the verbose message buffer.private voidexit(int exitValue) Exit this process.private booleanhasNextArgument(String msgId, String where, int i, int length) Check whether there is another parameter (the argument for an option that requires an argument).static voidRun the enhancer from the command line.private voidParse the command line arguments.private voidparseFiles(String[] fileNames, boolean search, boolean recurse) Files can be one of four types: directory: the directory is examined for files of the following types .class: this is a java class file .jdo: this is a jdo metadata file .jar: this is a jar file If the recursion flag is set, directories contained in directories are examined, recursively.private ClassLoaderprepareClassLoader(String classPath) Prepare the class loader from the classPath specifiedprivate voidprocessArgs(String[] args) Process the command line arguments and exit if there is a usage request or an error.private voidExecute the enhancer.private voidsetError()Set the error flag.private voidSet the print-and-exit flag.
-
Field Details
-
msg
The Internationalization message helper. -
NL
private char NLNew Line -
JAR_FILE_SUFFIX
Jar file suffix -
JDO_FILE_SUFFIX
JDO Metadata file suffix -
CLASS_FILE_SUFFIX
Class file suffix -
error
private boolean errorError indicator -
printAndExit
private boolean printAndExitIf set, process parameters, print usage, and exit. -
persistenceUnitNames
-
directoryName
Target Directory Parameter -
loader
ClassLoader for JDOEnhancer -
classPath
Classpath (-cp) parameter -
checkOnly
private boolean checkOnlyCheck Only flag -
verbose
private boolean verboseVerbose flag -
recurse
private boolean recurseRecurse flag -
errorBuffer
Error messages should be empty unless there is an error -
verboseBuffer
Verbose messages are always collected but only output if verbose flag is set -
fileNames
-
classFileNames
-
jdoFileNames
-
jarFileNames
-
numberOfValidatedClasses
private int numberOfValidatedClassesThe number of classes validated by the JDOEnhancer -
numberOfEnhancedClasses
private int numberOfEnhancedClassesThe number of classes enhanced by the JDOEnhancer -
properties
The properties from the JDOEnhancer
-
-
Constructor Details
-
Enhancer
public Enhancer()
-
-
Method Details
-
main
Run the enhancer from the command line.- Parameters:
args- command line arguments
-
run
-
processArgs
Process the command line arguments and exit if there is a usage request or an error.- Parameters:
args- the command line arguments
-
parseArgs
Parse the command line arguments. Put the results into fields.- Parameters:
args- the command line arguments
-
hasNextArgument
Check whether there is another parameter (the argument for an option that requires an argument).- Parameters:
msgId- the message id for an error messagewhere- the parameter for the messagei- the index into the parameter arraylength- the length of the parameter array- Returns:
-
parseFiles
Files can be one of four types:- directory: the directory is examined for files of the following types
- .class: this is a java class file
- .jdo: this is a jdo metadata file
- .jar: this is a jar file
-
prepareClassLoader
Prepare the class loader from the classPath specified- Parameters:
classPath- the classPath string from the "-cp classPath" option- Returns:
- the class loader
-
addErrorMessage
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
-
addVerboseMessage
-
addVerboseMessage
Add a message to the verbose message buffer.- Parameters:
msgId- the message id
-
addVerboseMessage
Add a message to the verbose message buffer.- Parameters:
msgId- the message idwhere- the parameter
-