Package javax.jdo
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 boolean
Check Only flagprivate String
Class file suffixClass File Namesprivate String
Classpath (-cp) parameterprivate String
Target Directory Parameterprivate boolean
Error indicatorprivate StringBuilder
Error messages should be empty unless there is an errorFile Namesprivate String
Jar file suffixJar File Namesprivate String
JDO Metadata file suffixJDO File Namesprivate ClassLoader
ClassLoader for JDOEnhancerprivate static final I18NHelper
The Internationalization message helper.private char
New Lineprivate int
The number of classes enhanced by the JDOEnhancerprivate int
The number of classes validated by the JDOEnhancerPersistence Unitsprivate boolean
If set, process parameters, print usage, and exit.private Properties
The properties from the JDOEnhancerprivate boolean
Recurse flagprivate boolean
Verbose flagprivate StringBuilder
Verbose messages are always collected but only output if verbose flag is set -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addErrorMessage
(String message) Add a message to stderr.private void
addVerboseMessage
(String msgId) Add a message to the verbose message buffer.private void
addVerboseMessage
(String msgId, int where) Add a message to the verbose message buffer.private void
addVerboseMessage
(String msgId, String where) Add a message to the verbose message buffer.private void
addVerboseMessage
(String msgId, String... where) Add a message to the verbose message buffer.private void
exit
(int exitValue) Exit this process.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).static void
Run the enhancer from the command line.private void
Parse the command line arguments.private void
parseFiles
(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 ClassLoader
prepareClassLoader
(String classPath) Prepare the class loader from the classPath specifiedprivate void
processArgs
(String[] args) Process the command line arguments and exit if there is a usage request or an error.private void
Execute the enhancer.private void
setError()
Set the error flag.private void
Set 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
Persistence Units -
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
File Names -
classFileNames
Class File Names -
jdoFileNames
JDO File Names -
jarFileNames
Jar File Names -
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
Execute the enhancer.- Parameters:
args
- the command line arguments
-
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
Add a message to the verbose message buffer.- Parameters:
msgId
- the message idwhere
- the parameter
-
addVerboseMessage
Add a message to the verbose message buffer.- Parameters:
msgId
- the message idwhere
- the parameter
-
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
-