Package javax.jdo
Class Enhancer
- java.lang.Object
-
- javax.jdo.Enhancer
-
public class Enhancer extends java.lang.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 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
Fields Modifier and Type Field Description private boolean
checkOnly
Check Only flagprivate java.lang.String
CLASS_FILE_SUFFIX
Class file suffixprivate java.util.List<java.lang.String>
classFileNames
Class File Namesprivate java.lang.String
classPath
Classpath (-cp) parameterprivate java.lang.String
directoryName
Target Directory Parameterprivate boolean
error
Error indicatorprivate java.lang.StringBuilder
errorBuffer
Error messages should be empty unless there is an errorprivate java.util.List<java.lang.String>
fileNames
File Namesprivate java.lang.String
JAR_FILE_SUFFIX
Jar file suffixprivate java.util.List<java.lang.String>
jarFileNames
Jar File Namesprivate java.lang.String
JDO_FILE_SUFFIX
JDO Metadata file suffixprivate java.util.List<java.lang.String>
jdoFileNames
JDO File Namesprivate java.lang.ClassLoader
loader
ClassLoader for JDOEnhancerprivate static I18NHelper
msg
The Internationalization message helper.private char
NL
New Lineprivate int
numberOfEnhancedClasses
The number of classes enhanced by the JDOEnhancerprivate int
numberOfValidatedClasses
The number of classes validated by the JDOEnhancerprivate java.util.List<java.lang.String>
persistenceUnitNames
Persistence Unitsprivate boolean
printAndExit
If set, process parameters, print usage, and exit.private java.util.Properties
properties
The properties from the JDOEnhancerprivate boolean
recurse
Recurse flagprivate boolean
verbose
Verbose flagprivate java.lang.StringBuilder
verboseBuffer
Verbose messages are always collected but only output if verbose flag is set
-
Constructor Summary
Constructors Constructor Description Enhancer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addErrorMessage(java.lang.String message)
Add a message to stderr.private void
addVerboseMessage(java.lang.String msgId)
Add a message to the verbose message buffer.private void
addVerboseMessage(java.lang.String msgId, int where)
Add a message to the verbose message buffer.private void
addVerboseMessage(java.lang.String msgId, java.lang.String where)
Add a message to the verbose message buffer.private void
addVerboseMessage(java.lang.String msgId, java.lang.String... where)
Add a message to the verbose message buffer.private void
exit(int exitValue)
Exit this process.private boolean
hasNextArgument(java.lang.String msgId, java.lang.String where, int i, int length)
Check whether there is another parameter (the argument for an option that requires an argument).static void
main(java.lang.String[] args)
Run the enhancer from the command line.private void
parseArgs(java.lang.String[] args)
Parse the command line arguments.private void
parseFiles(java.lang.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 java.lang.ClassLoader
prepareClassLoader(java.lang.String classPath)
Prepare the class loader from the classPath specifiedprivate void
processArgs(java.lang.String[] args)
Process the command line arguments and exit if there is a usage request or an error.private void
run(java.lang.String[] args)
Execute the enhancer.private void
setError()
Set the error flag.private void
setPrintAndExit()
Set the print-and-exit flag.
-
-
-
Field Detail
-
msg
private static final I18NHelper msg
The Internationalization message helper.
-
NL
private char NL
New Line
-
JAR_FILE_SUFFIX
private java.lang.String JAR_FILE_SUFFIX
Jar file suffix
-
JDO_FILE_SUFFIX
private java.lang.String JDO_FILE_SUFFIX
JDO Metadata file suffix
-
CLASS_FILE_SUFFIX
private java.lang.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 java.util.List<java.lang.String> persistenceUnitNames
Persistence Units
-
directoryName
private java.lang.String directoryName
Target Directory Parameter
-
loader
private java.lang.ClassLoader loader
ClassLoader for JDOEnhancer
-
classPath
private java.lang.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 java.lang.StringBuilder errorBuffer
Error messages should be empty unless there is an error
-
verboseBuffer
private java.lang.StringBuilder verboseBuffer
Verbose messages are always collected but only output if verbose flag is set
-
fileNames
private java.util.List<java.lang.String> fileNames
File Names
-
classFileNames
private java.util.List<java.lang.String> classFileNames
Class File Names
-
jdoFileNames
private java.util.List<java.lang.String> jdoFileNames
JDO File Names
-
jarFileNames
private java.util.List<java.lang.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 java.util.Properties properties
The properties from the JDOEnhancer
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
Run the enhancer from the command line.- Parameters:
args
- command line arguments
-
run
private void run(java.lang.String[] args)
Execute the enhancer.- Parameters:
args
- the command line arguments
-
processArgs
private void processArgs(java.lang.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(java.lang.String[] args)
Parse the command line arguments. Put the results into fields.- Parameters:
args
- the command line arguments
-
hasNextArgument
private boolean hasNextArgument(java.lang.String msgId, java.lang.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 messagewhere
- the parameter for the messagei
- the index into the parameter arraylength
- the length of the parameter array- Returns:
-
parseFiles
private void parseFiles(java.lang.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
-
prepareClassLoader
private java.lang.ClassLoader prepareClassLoader(java.lang.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(java.lang.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(java.lang.String msgId, java.lang.String... where)
Add a message to the verbose message buffer.- Parameters:
msgId
- the message idwhere
- the parameter
-
addVerboseMessage
private void addVerboseMessage(java.lang.String msgId, java.lang.String where)
Add a message to the verbose message buffer.- Parameters:
msgId
- the message idwhere
- the parameter
-
addVerboseMessage
private void addVerboseMessage(java.lang.String msgId)
Add a message to the verbose message buffer.- Parameters:
msgId
- the message id
-
addVerboseMessage
private void addVerboseMessage(java.lang.String msgId, int where)
Add a message to the verbose message buffer.- Parameters:
msgId
- the message idwhere
- the parameter
-
-