javax.jdo
Interface JDOEnhancer

All Superinterfaces:
java.lang.instrument.ClassFileTransformer

public interface JDOEnhancer
extends java.lang.instrument.ClassFileTransformer

Interface for a JDO Enhancer.

Since:
2.3

Method Summary
 JDOEnhancer addClass(java.lang.String className, byte[] bytes)
          Add an in-memory class to the items to be enhanced.
 JDOEnhancer addClasses(java.lang.String... classNames)
          Add class(es) to the items to be enhanced.
 JDOEnhancer addFiles(java.lang.String... metadataFiles)
          Add metadata file(s) to the items to be enhanced.
 JDOEnhancer addJar(java.lang.String jarFileName)
          Add a jar file to the items to be enhanced.
 JDOEnhancer addPersistenceUnit(java.lang.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(java.lang.String className)
          Method to retrieve the (enhanced) bytes of the specified class.
 java.util.Properties getProperties()
          Return non-configurable properties of this JDOEnhancer.
 JDOMetadata newMetadata()
          Method to return a new metadata object that can be subsequently modified and registered with the enhancement process using the method registerMetadata(javax.jdo.metadata.JDOMetadata).
 void registerMetadata(JDOMetadata metadata)
          Method to register metadata with the enhancement process managed by this JDOEnhancer.
 JDOEnhancer setClassLoader(java.lang.ClassLoader loader)
          Mutator to set the class loader to use for loading classes.
 JDOEnhancer setOutputDirectory(java.lang.String dirName)
          Mutator to set the location where enhanced classes are written.
 JDOEnhancer setVerbose(boolean flag)
          Whether to provide verbose output
 int validate()
          Method to validate the items specified using addJar, addFiles, addClasses, addClass, addPersistenceUnit.
 
Methods inherited from interface java.lang.instrument.ClassFileTransformer
transform
 

Method Detail

getProperties

java.util.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

JDOEnhancer setVerbose(boolean flag)
Whether to provide verbose output

Parameters:
flag - Verbose?
Returns:
The enhancer

setOutputDirectory

JDOEnhancer setOutputDirectory(java.lang.String dirName)
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

JDOEnhancer setClassLoader(java.lang.ClassLoader loader)
Mutator to set the class loader to use for loading classes.

Parameters:
loader - ClassLoader to use
Returns:
The enhancer

addPersistenceUnit

JDOEnhancer addPersistenceUnit(java.lang.String persistenceUnit)
Add a persistence-unit to the items to be enhanced.

Parameters:
persistenceUnit - Name of the persistence unit
Returns:
The enhancer

addClass

JDOEnhancer addClass(java.lang.String className,
                     byte[] bytes)
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 class
bytes - The bytes of the class
Returns:
The enhancer

addClasses

JDOEnhancer addClasses(java.lang.String... classNames)
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

JDOEnhancer addFiles(java.lang.String... metadataFiles)
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

JDOEnhancer addJar(java.lang.String jarFileName)
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

byte[] getEnhancedBytes(java.lang.String className)
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

void registerMetadata(JDOMetadata metadata)
Method to register metadata with the enhancement process managed by this JDOEnhancer. Metadata can be created using the method newMetadata(). 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:
2.3

newMetadata

JDOMetadata newMetadata()
Method to return a new metadata object that can be subsequently modified and registered with the enhancement process using the method registerMetadata(javax.jdo.metadata.JDOMetadata).

Returns:
The metadata
Since:
2.3


Copyright © 2005-2009 Apache Software Foundation. All Rights Reserved.