|
||||||||||
| 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 ClassLoader |
userClassLoader
User-provided class loader. |
| Constructor Summary | |
|---|---|
DataNucleusEnhancer()
Constructor for an enhancer for JDO. |
|
DataNucleusEnhancer(String api)
Constructor for an enhancer specifying the API. |
|
DataNucleusEnhancer(String apiName,
Properties props)
Constructor for an enhancer specifying the API and class enhancer and optional properties. |
|
| Method Summary | |
|---|---|
DataNucleusEnhancer |
addClass(String className,
byte[] bytes)
Method to add the specified class (and its input bytes) to the list of classes to enhance. |
DataNucleusEnhancer |
addClasses(String... classNames)
Method to add the specified classes to the list of classes to enhance. |
DataNucleusEnhancer |
addFiles(String... filenames)
Method to add the specified files to the list of components to enhance. |
DataNucleusEnhancer |
addJar(String jarFileName)
Method to add the classes defined by the specified jar to the list of components to enhance. |
protected void |
addMessage(String msg,
boolean error)
Method to add a message at the required output level. |
DataNucleusEnhancer |
addPersistenceUnit(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. |
ClassLoader |
getClassLoader()
Accessor for the user-defined class loader for enhancement (if any). |
byte[] |
getEnhancedBytes(String className)
Accessor for the enhanced bytes of any classes just enhanced. |
protected 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. |
String |
getOutputDirectory()
Acessor for the output directory. |
byte[] |
getPkClassBytes(String className)
Accessor for the bytes of any pk classes just created. |
Properties |
getProperties()
Accessor for global properties defining this enhancer. |
boolean |
isVerbose()
Acessor for the verbose |
static void |
main(String[] args)
Entry point for command line enhancer. |
protected void |
resetEnhancement()
Method to throw away any previously stored enhancement results. |
DataNucleusEnhancer |
setClassLoader(ClassLoader loader)
Method to set the class loader to use for loading the class(es) to be enhanced. |
DataNucleusEnhancer |
setDetachListener(boolean flag)
Mutator for whether to allow generation of default constructor where needed. |
DataNucleusEnhancer |
setGenerateConstructor(boolean flag)
Mutator for whether to allow generation of default constructor where needed. |
DataNucleusEnhancer |
setGeneratePK(boolean flag)
Mutator for whether to allow generation of PKs where needed. |
DataNucleusEnhancer |
setOutputDirectory(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 final org.datanucleus.util.Localiser LOCALISER
public static final org.datanucleus.util.NucleusLogger LOGGER
protected ClassLoader userClassLoader
| Constructor Detail |
|---|
public DataNucleusEnhancer()
public DataNucleusEnhancer(String api)
api - The API to use.
public DataNucleusEnhancer(String apiName,
Properties props)
apiName - Name of the API to use; defines which MetaDataManager to utilise.props - properties controlling enhancement| Method Detail |
|---|
public org.datanucleus.metadata.MetaDataManager getMetaDataManager()
public String getOutputDirectory()
public DataNucleusEnhancer setOutputDirectory(String dir)
dir - the output directory
public ClassLoader getClassLoader()
public DataNucleusEnhancer setClassLoader(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 setGeneratePK(boolean flag)
flag - Whether to enable this
public DataNucleusEnhancer setGenerateConstructor(boolean flag)
flag - Whether to enable this
public DataNucleusEnhancer setDetachListener(boolean flag)
flag - Whether to enable this
public DataNucleusEnhancer addClass(String className,
byte[] bytes)
className - Name of the class (in the format "mydomain.MyClass")bytes - Bytes of the class
public DataNucleusEnhancer addClasses(String... classNames)
classNames - Names of the classes
public DataNucleusEnhancer addFiles(String... filenames)
filenames - Names of the files
public DataNucleusEnhancer addJar(String jarFileName)
jarFileName - Name of the jar file
public DataNucleusEnhancer addPersistenceUnit(String persistenceUnitName)
persistenceUnitName - Name of the persistence-unit
public int enhance()
public int validate()
protected Collection<org.datanucleus.metadata.FileMetaData> getFileMetadataForInput()
public byte[] getEnhancedBytes(String className)
className - Name of the class
org.datanucleus.exceptions.NucleusException - if no bytes are available for the specified classpublic byte[] getPkClassBytes(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 void addMessage(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 Properties getProperties()
public static void main(String[] args)
throws Exception
args - Command line arguments
Exception - Thrown if an error occurs
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||