Package javax.jdo
Interface JDOEnhancer
- All Superinterfaces:
ClassFileTransformer
Interface for a JDO Enhancer.
- Since:
- 3.0
-
Method Summary
Modifier and TypeMethodDescriptionAdd an in-memory class to the items to be enhanced.addClasses
(String... classNames) Add class(es) to the items to be enhanced.Add metadata file(s) to the items to be enhanced.Add a jar file to the items to be enhanced.addPersistenceUnit
(String persistenceUnit) Add a persistence-unit to the items to be enhanced.int
enhance()
Method to enhance the items specified using addJar, addFiles, addClasses, addClass, addPersistenceUnit.byte[]
getEnhancedBytes
(String className) Method to retrieve the (enhanced) bytes of the specified class.Return non-configurable properties of this JDOEnhancer.Method to return a new metadata object that can be subsequently modified and registered with the enhancement process using the methodregisterMetadata(javax.jdo.metadata.JDOMetadata)
.void
registerMetadata
(JDOMetadata metadata) Method to register metadata with the enhancement process managed by thisJDOEnhancer
.setClassLoader
(ClassLoader loader) Mutator to set the class loader to use for loading classes.setOutputDirectory
(String dirName) Mutator to set the location where enhanced classes are written.setVerbose
(boolean flag) Whether to provide verbose outputint
validate()
Method to validate the items specified using addJar, addFiles, addClasses, addClass, addPersistenceUnit.Methods inherited from interface java.lang.instrument.ClassFileTransformer
transform
-
Method Details
-
getProperties
Properties getProperties()Return non-configurable properties of this JDOEnhancer. Properties with keys "VendorName" and "VersionNumber" are required. Other keys are optional.- Returns:
- the non-configurable properties of this JDOEnhancer.
-
setVerbose
Whether to provide verbose output- Parameters:
flag
- Verbose?- Returns:
- The enhancer
-
setOutputDirectory
Mutator to set the location where enhanced classes are written. Mutator to set the location where enhanced classes are written. If this method is not called, classes will be enhanced in place, overwriting the existing classes. If overwriting classes in a jar file, the existing files in the jar file will be written unchanged except for the enhanced classes. The directory name can be absolute or relative.- Parameters:
dirName
- Name of the directory- Returns:
- The enhancer
-
setClassLoader
Mutator to set the class loader to use for loading classes.- Parameters:
loader
- ClassLoader to use- Returns:
- The enhancer
-
addPersistenceUnit
Add a persistence-unit to the items to be enhanced.- Parameters:
persistenceUnit
- Name of the persistence unit- Returns:
- The enhancer
-
addClass
Add an in-memory class to the items to be enhanced. The class name should be of the form "mydomain.MyClass".- Parameters:
className
- Name of the classbytes
- The bytes of the class- Returns:
- The enhancer
-
addClasses
Add class(es) to the items to be enhanced. The class names can be absolute file names, relative file names, or names of CLASSPATH resources.- Parameters:
classNames
- Names of the classes- Returns:
- The enhancer
-
addFiles
Add metadata file(s) to the items to be enhanced. The metadata file names can be absolute file names, relative file names, or names of CLASSPATH resources. They should be JDO XML metadata files.- Parameters:
metadataFiles
- Names of the files- Returns:
- The enhancer
-
addJar
Add a jar file to the items to be enhanced. The jar file name can be absolute, or relative or a CLASSPATH resource.- Parameters:
jarFileName
- Name of the jar file- Returns:
- The enhancer
-
enhance
int enhance()Method to enhance the items specified using addJar, addFiles, addClasses, addClass, addPersistenceUnit.- Returns:
- Number of classes enhanced
- Throws:
JDOEnhanceException
- if an error occurs during enhancement. If multiple errors occur then the nested exceptions provides this detail.
-
validate
int validate()Method to validate the items specified using addJar, addFiles, addClasses, addClass, addPersistenceUnit.- Returns:
- Number of classes validated
- Throws:
JDOEnhanceException
- if an error occurs during validation. If multiple errors occur then the nested exceptions provides this detail.
-
getEnhancedBytes
Method to retrieve the (enhanced) bytes of the specified class. Only applies to the classes enhanced in the most recent enhance() call. If no enhance has yet been performed will throw a JDOEnhanceException. If the specified class hasn't been enhanced then will throw a JDOEnhanceException.- Parameters:
className
- Name of the class (of the form "mydomain.MyClass")- Returns:
- Enhanced bytes
-
registerMetadata
Method to register metadata with the enhancement process managed by thisJDOEnhancer
. Metadata can be created using the methodnewMetadata()
. If there is already metadata registered for a class contained in this metadata object then a JDOUserException will be thrown.- Parameters:
metadata
- The Metadata to register.- Since:
- 3.0
-
newMetadata
JDOMetadata newMetadata()Method to return a new metadata object that can be subsequently modified and registered with the enhancement process using the methodregisterMetadata(javax.jdo.metadata.JDOMetadata)
.- Returns:
- The metadata
- Since:
- 3.0
-