Package org.apache.openjpa.enhance
Class ApplicationIdTool
java.lang.Object
org.apache.openjpa.enhance.ApplicationIdTool
Generates a class appropriate for use as an application identity class.
- Author:
- Patrick Linskey, Abe White
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Run flags.static interface
Interface implemented by metadata factories that can load non-existant object id classes. -
Field Summary
-
Constructor Summary
ConstructorDescriptionApplicationIdTool
(OpenJPAConfiguration conf, Class type) Constructs a new ApplicationIdTool capable of generating an object id class fortype
.ApplicationIdTool
(OpenJPAConfiguration conf, Class type, ClassMetaData meta) Constructs a new tool instance capable of generating an object id class formeta
. -
Method Summary
Modifier and TypeMethodDescriptiongetCode()
Return the code generated for the application id, or null if invalid class or therun()
method has not been called.The code formatter for the generated Java code.The directory to write source to.boolean
Return false if this tool is configured to throw an exception on an attempt to generate an id class for a type that does not use application identity.Returns the collection of packages that need to be imported.Return metadata for the type we are generating an application id for.getToken()
The token to use to separate stringified primary key field values.getType()
Return the type we are generating an application id for.The writer to write source to, or null to write to default file.boolean
Returns true if the application identity class should be an inner class.static void
Usage: java org.apache.openjpa.enhance.ApplicationIdTool [option]* <class name | .java file | .class file | .jdo file>+ Where the following options are recognized.void
record()
Writes the generated code to the proper file.boolean
run()
Generates the sourcecode for the application id class; returns false if the class is invalid.static boolean
run
(OpenJPAConfiguration conf, String[] args, ApplicationIdTool.Flags flags, ClassLoader loader) Run the tool.static boolean
run
(OpenJPAConfiguration conf, String[] args, Options opts) Run the application id tool with the given command-line and given configuration.void
setCodeFormat
(CodeFormat format) Set the code formatter for the generated Java code.void
setDirectory
(File dir) The directory to write source to.void
setIgnoreErrors
(boolean ignore) Set to false if this tool should throw an exception on an attempt to generate an id class for a type that does not use application identity.void
The token to use to separate stringified primary key field values.void
The writer to write source to, or null to write to default file.
-
Field Details
-
TOKEN_DEFAULT
- See Also:
-
-
Constructor Details
-
ApplicationIdTool
Constructs a new ApplicationIdTool capable of generating an object id class fortype
. -
ApplicationIdTool
Constructs a new tool instance capable of generating an object id class formeta
.
-
-
Method Details
-
getIgnoreErrors
public boolean getIgnoreErrors()Return false if this tool is configured to throw an exception on an attempt to generate an id class for a type that does not use application identity. -
setIgnoreErrors
public void setIgnoreErrors(boolean ignore) Set to false if this tool should throw an exception on an attempt to generate an id class for a type that does not use application identity. -
getCodeFormat
The code formatter for the generated Java code. -
setCodeFormat
Set the code formatter for the generated Java code. -
getDirectory
The directory to write source to. Defaults to the directory of the Java file for the set type. If the given directory does not match the package of the object id, the package structure will be created below the directory. -
setDirectory
The directory to write source to. Defaults to the directory of the Java file for the set type. If the given directory does not match the package of the object id, the package structure will be created below the directory. -
getToken
The token to use to separate stringified primary key field values. -
setToken
The token to use to separate stringified primary key field values. -
getWriter
The writer to write source to, or null to write to default file. -
setWriter
The writer to write source to, or null to write to default file. -
getType
Return the type we are generating an application id for. -
getMetaData
Return metadata for the type we are generating an application id for. -
getCode
Return the code generated for the application id, or null if invalid class or therun()
method has not been called. -
isInnerClass
public boolean isInnerClass()Returns true if the application identity class should be an inner class. -
run
public boolean run()Generates the sourcecode for the application id class; returns false if the class is invalid. -
record
Writes the generated code to the proper file.- Throws:
IOException
-
getImportPackages
Returns the collection of packages that need to be imported. -
main
Usage: java org.apache.openjpa.enhance.ApplicationIdTool [option]* <class name | .java file | .class file | .jdo file>+ Where the following options are recognized.- -properties/-p <properties file>: The path to a OpenJPA
properties file containing information as outlined in
Configuration
; optional. - -<property name> <property value>: All bean
properties of the standard OpenJPA
OpenJPAConfiguration
can be set by using their names and supplying a value. - -directory/-d <output directory>: Path to the base source directory. The package structure will be created beneath this directory if necessary. If not specified, the tool will try to locate the .java file in the CLASSPATH and output to the same directory; failing that, it will use the current directory as the base directory.
- -ignoreErrors/-i <true/t | false/f>: If false, an exception will be thrown if the tool encounters any class that does not use application identity or uses the identity class of its superclass; defaults to true.
- -token/-t <token>: The token to use to separate stingified primary key field values in the stringified oid.
- -name/-n <id class name>: The name of the identity class to generate. If this option is specified, you must only give a single class argument. If the class metadata names an object id class, this argument is ignored.
- -suffix/-s <id class suffix>: A string to suffix each
persistent class with to create the identity class name. This is
overridden by
-name
or by any identity class name specified in metadata. - -codeFormat/-cf.<property name> < property value>
: Arguments like this will be used to configure the bean
properties of the internal
CodeFormat
.
- Throws:
IOException
ClassNotFoundException
- -properties/-p <properties file>: The path to a OpenJPA
properties file containing information as outlined in
-
run
public static boolean run(OpenJPAConfiguration conf, String[] args, Options opts) throws IOException, ClassNotFoundException Run the application id tool with the given command-line and given configuration. Returns false if invalid options were given.- Throws:
IOException
ClassNotFoundException
-
run
public static boolean run(OpenJPAConfiguration conf, String[] args, ApplicationIdTool.Flags flags, ClassLoader loader) throws IOException, ClassNotFoundException Run the tool. Returns false if invalid options were given.- Throws:
IOException
ClassNotFoundException
-