|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.datanucleus.enhancer.DataNucleusEnhancer
public class DataNucleusEnhancer
DataNucleus Byte-Code Enhancer. This provides the entry point for enhancement. Enhancement is performed using a ClassEnhancer. Currently provides a ClassEnhancer using ASM.
You can use the DataNucleusEnhancer in two ways :-
The programmatic way would be something like this :-
DataNucleusEnhancer enhancer = new DataNucleusEnhancer();
enhancer.setVerbose();
enhancer.enhancePersistenceUnit("myPersistenceUnit");
enhancing all classes specified by the persistence unit.
| Field Summary | |
|---|---|
protected static org.datanucleus.util.Localiser |
LOCALISER
|
static org.datanucleus.util.NucleusLogger |
LOGGER
Logger for enhancing. |
protected java.lang.ClassLoader |
userClassLoader
User-provided class loader. |
| Constructor Summary | |
|---|---|
DataNucleusEnhancer()
Constructor for an enhancer for JDO using the ASM class enhancer. |
|
DataNucleusEnhancer(java.lang.String api,
java.lang.String enhancerName)
Constructor for an enhancer specifying the API and class enhancer. |
|
DataNucleusEnhancer(java.lang.String api,
java.lang.String enhancerName,
java.util.Properties props)
Constructor for an enhancer specifying the API and class enhancer and optional properties. |
|
| Method Summary | |
|---|---|
DataNucleusEnhancer |
addClass(java.lang.String className,
byte[] bytes)
Method to add the specified class (and its input bytes) to the list of classes to enhance. |
DataNucleusEnhancer |
addClasses(java.lang.String... classNames)
Method to add the specified classes to the list of classes to enhance. |
DataNucleusEnhancer |
addFiles(java.lang.String... filenames)
Method to add the specified files to the list of components to enhance. |
DataNucleusEnhancer |
addJar(java.lang.String jarFileName)
Method to add the classes defined by the specified jar to the list of components to enhance. |
protected void |
addMessage(java.lang.String msg,
boolean error)
Method to add a message at the required output level. |
DataNucleusEnhancer |
addPersistenceUnit(java.lang.String persistenceUnitName)
Method to add the classes defined by the persistence-unit to the list of classes to enhance. |
int |
enhance()
Method to enhance all classes defined by addClass, addClasses, addJar, addPersistenceUnit, addFiles. |
protected boolean |
enhanceClass(org.datanucleus.metadata.ClassMetaData cmd,
ClassEnhancer enhancer,
boolean store)
Method to enhance the class defined by the MetaData. |
protected ClassEnhancer |
getClassEnhancer(org.datanucleus.metadata.ClassMetaData cmd,
byte[] bytes)
Method to return an instance of the ClassEnhancer for use with this class. |
java.lang.ClassLoader |
getClassLoader()
Accessor for the user-defined class loader for enhancement (if any). |
protected java.lang.String |
getClassNameForFilename(java.lang.String filename)
Convenience method to get the class name (mydomain.MyClass) from the filename. |
byte[] |
getEnhancedBytes(java.lang.String className)
Accessor for the enhanced bytes of any classes just enhanced. |
protected java.util.Collection<org.datanucleus.metadata.FileMetaData> |
getFileMetadataForInput()
Method that processes the registered components to enhance, and loads the metadata for them into the MetaDataManager, returning the associated FileMetaData. |
org.datanucleus.metadata.MetaDataManager |
getMetaDataManager()
Accessor for the MetaDataManager. |
java.lang.String |
getOutputDirectory()
Acessor for the output directory. |
java.util.Properties |
getProperties()
Accessor for global properties defining this enhancer. |
protected static java.lang.String |
getVendorName()
Utility to get the vendor of Enhancer. |
protected static java.lang.String |
getVersionNumber()
Utility to get the version of Enhancer. |
boolean |
isVerbose()
Acessor for the verbose |
static void |
main(java.lang.String[] args)
Entry point for command line enhancer. |
protected void |
resetEnhancement()
Method to throw away any previously stored enhancement results. |
DataNucleusEnhancer |
setClassLoader(java.lang.ClassLoader loader)
Method to set the class loader to use for loading the class(es) to be enhanced. |
DataNucleusEnhancer |
setOutputDirectory(java.lang.String dir)
Mutator for the output directory where any classes will be written. |
DataNucleusEnhancer |
setSystemOut(boolean sysout)
Mutator for whether to output to system out. |
DataNucleusEnhancer |
setVerbose(boolean verbose)
Mutator for the verbose flag |
int |
validate()
Method to validate all classes defined by addClass, addClasses, addJar, addPersistenceUnit, addFiles. |
protected boolean |
validateClass(org.datanucleus.metadata.ClassMetaData cmd,
ClassEnhancer enhancer)
Method to validate the enhancement state of the class defined by the MetaData. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static org.datanucleus.util.Localiser LOCALISER
public static final org.datanucleus.util.NucleusLogger LOGGER
protected java.lang.ClassLoader userClassLoader
| Constructor Detail |
|---|
public DataNucleusEnhancer()
public DataNucleusEnhancer(java.lang.String api,
java.lang.String enhancerName)
api - The API to use.enhancerName - Name of the class enhancer.
public DataNucleusEnhancer(java.lang.String api,
java.lang.String enhancerName,
java.util.Properties props)
api - The API to use.enhancerName - Name of the class enhancer.props - properties controlling enhancement| Method Detail |
|---|
public org.datanucleus.metadata.MetaDataManager getMetaDataManager()
public java.lang.String getOutputDirectory()
public DataNucleusEnhancer setOutputDirectory(java.lang.String dir)
dir - the output directory
public java.lang.ClassLoader getClassLoader()
public DataNucleusEnhancer setClassLoader(java.lang.ClassLoader loader)
loader - The loader
public boolean isVerbose()
public DataNucleusEnhancer setVerbose(boolean verbose)
verbose - the verbose to set
public DataNucleusEnhancer setSystemOut(boolean sysout)
sysout - Whether to use sysout
public DataNucleusEnhancer addClass(java.lang.String className,
byte[] bytes)
className - Name of the class (in the format "mydomain.MyClass")bytes - Bytes of the class
public DataNucleusEnhancer addClasses(java.lang.String... classNames)
classNames - Names of the classes
public DataNucleusEnhancer addFiles(java.lang.String... filenames)
filenames - Names of the files
public DataNucleusEnhancer addJar(java.lang.String jarFileName)
jarFileName - Name of the jar file
public DataNucleusEnhancer addPersistenceUnit(java.lang.String persistenceUnitName)
persistenceUnitName - Name of the persistence-unit
public int enhance()
public int validate()
protected java.util.Collection<org.datanucleus.metadata.FileMetaData> getFileMetadataForInput()
public byte[] getEnhancedBytes(java.lang.String className)
className - Name of the class
org.datanucleus.exceptions.NucleusException - if no bytes are available for the specified classprotected void resetEnhancement()
protected ClassEnhancer getClassEnhancer(org.datanucleus.metadata.ClassMetaData cmd,
byte[] bytes)
cmd - MetaData for the classbytes - Bytes (if provided)
protected java.lang.String getClassNameForFilename(java.lang.String filename)
filename - Name of the file
protected void addMessage(java.lang.String msg,
boolean error)
msg - The messageerror - Whether the message is an error, so log at error level (otherwise info)
protected boolean enhanceClass(org.datanucleus.metadata.ClassMetaData cmd,
ClassEnhancer enhancer,
boolean store)
cmd - MetaData for the classenhancer - ClassEnhancer to usestore - Whether to store the class after enhancing
protected boolean validateClass(org.datanucleus.metadata.ClassMetaData cmd,
ClassEnhancer enhancer)
cmd - MetaData for the classenhancer - ClassEnhancer to use
public java.util.Properties getProperties()
public static void main(java.lang.String[] args)
throws java.lang.Exception
args - Command line arguments
java.lang.Exception - Thrown if an error occursprotected static java.lang.String getVersionNumber()
protected static java.lang.String getVendorName()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||