|
||||||||||
| 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, and a deprecated one using Apache BCEL.
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. |
|
| 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[] metadataFiles)
Method to add the classes defined in specified metadata files to the list of classes to enhance. |
DataNucleusEnhancer |
addJar(java.lang.String jarFileName)
Method to add the classes defined by the specified jar to the list of classes 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. |
void |
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. |
byte[] |
enhanceClass(java.lang.String className,
byte[] bytes)
Method to enhance the supplied (in-memory) class from its bytes. |
int |
enhanceFiles(java.lang.String[] filenames)
Method to enhance the classes defined by the input files. |
int |
enhancePersistenceUnit(java.lang.String persistentUnitName)
Method to enhance the classes defined by the specified persistence-unit. |
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). |
org.datanucleus.ClassLoaderResolver |
getClassLoaderResolver()
|
java.lang.String |
getDestination()
Deprecated. Use getOutputDirectory() instead |
byte[] |
getEnhancedBytes(java.lang.String className)
Accessor for the enhanced bytes of any classes just enhanced. |
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 |
isCheckonly()
Accessor for whether we are just checking for enhancement state. |
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 |
setCheckonly(boolean checkonly)
Method to set whether we should just check for enhancement state. |
DataNucleusEnhancer |
setClassLoader(java.lang.ClassLoader loader)
Method to set the class loader to use for loading the class(es) to be enhanced. |
DataNucleusEnhancer |
setDestination(java.lang.String dir)
Deprecated. Use setOutputDirectory() instead |
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 |
void |
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.| Method Detail |
|---|
public org.datanucleus.metadata.MetaDataManager getMetaDataManager()
public org.datanucleus.ClassLoaderResolver getClassLoaderResolver()
public boolean isCheckonly()
public DataNucleusEnhancer setCheckonly(boolean checkonly)
checkonly - Whether to check
public java.lang.String getOutputDirectory()
public DataNucleusEnhancer setOutputDirectory(java.lang.String dir)
dir - the output directory
public java.lang.String getDestination()
public DataNucleusEnhancer setDestination(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 classbytes - Bytes of the class
public DataNucleusEnhancer addClasses(java.lang.String[] classNames)
classNames - Names of the classes
public DataNucleusEnhancer addFiles(java.lang.String[] metadataFiles)
metadataFiles - Names of the metadata 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 void enhance()
public void validate()
public byte[] getEnhancedBytes(java.lang.String className)
className - Name of the class
protected void resetEnhancement()
public byte[] enhanceClass(java.lang.String className,
byte[] bytes)
className - Name of the classbytes - The bytes
public int enhanceFiles(java.lang.String[] filenames)
filenames - Names of files to enhance
NucleusEnhanceException - If an error occurspublic int enhancePersistenceUnit(java.lang.String persistentUnitName)
persistentUnitName - Name of persistence-unit to enhance
NucleusEnhanceException - If an error occurs
protected ClassEnhancer getClassEnhancer(org.datanucleus.metadata.ClassMetaData cmd,
byte[] bytes)
cmd - MetaData for the classbytes - Bytes (if provided)
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 | |||||||||