Package org.datanucleus.enhancer
Interface ClassEnhancer
-
- All Known Implementing Classes:
ClassEnhancerImpl
public interface ClassEnhancerInterface representation of an enhancer of a class.
-
-
Field Summary
Fields Modifier and Type Field Description static intASM_API_VERSIONVersion of the ASM API to use (introduced in ASM v4 to aid backward compatibility).static StringOPTION_GENERATE_DEFAULT_CONSTRUCTOROption for generating the default constructor.static StringOPTION_GENERATE_DETACH_LISTENEROption for use the detach listener.static StringOPTION_GENERATE_PKOption for generating the default constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanenhance()Method to enhance the class definition internally.StringgetASMClassName()Accessor for the ASM class name for the class being enhanced.ClassgetClassBeingEnhanced()Accessor for the class being enhanced.byte[]getClassBytes()Access the class bytecode.StringgetClassDescriptor()Accessor for the class descriptor for the class being enhancedClassLoaderResolvergetClassLoaderResolver()Accessor for the ClassLoaderResolver in use.ClassMetaDatagetClassMetaData()Accessor for the ClassMetaData for the class.StringgetClassName()Accessor for the name of the class being enhanced.List<ClassField>getFieldsList()Accessor for the fields required.MetaDataManagergetMetaDataManager()Accessor for the MetaData manager in use.List<ClassMethod>getMethodsList()Accessor for the methods required.EnhancementNamergetNamer()byte[]getPrimaryKeyClassBytes()Access the generated primary-key class bytecode.booleanhasOption(String name)Accessor for whether a particular option is enabled.booleanisPersistable(String className)Check if the class is Persistable or is going to be enhanced based on the metadatavoidsave(String directoryName)Method to save the (current) class definition bytecode into a class file.voidsetNamer(EnhancementNamer namer)voidsetOptions(Collection<String> options)Method to set the options controlling the enhancement.booleanvalidate()Validate whether the class is enhanced.
-
-
-
Field Detail
-
ASM_API_VERSION
static final int ASM_API_VERSION
Version of the ASM API to use (introduced in ASM v4 to aid backward compatibility).- See Also:
- Constant Field Values
-
OPTION_GENERATE_DEFAULT_CONSTRUCTOR
static final String OPTION_GENERATE_DEFAULT_CONSTRUCTOR
Option for generating the default constructor.- See Also:
- Constant Field Values
-
OPTION_GENERATE_PK
static final String OPTION_GENERATE_PK
Option for generating the default constructor.- See Also:
- Constant Field Values
-
OPTION_GENERATE_DETACH_LISTENER
static final String OPTION_GENERATE_DETACH_LISTENER
Option for use the detach listener.- See Also:
- Constant Field Values
-
-
Method Detail
-
setOptions
void setOptions(Collection<String> options)
Method to set the options controlling the enhancement.- Parameters:
options- The options
-
hasOption
boolean hasOption(String name)
Accessor for whether a particular option is enabled.- Parameters:
name- Name of the option- Returns:
- Whether it has this option
-
validate
boolean validate()
Validate whether the class is enhanced.- Returns:
- Return true if already enhanced class.
-
enhance
boolean enhance()
Method to enhance the class definition internally.- Returns:
- Whether the class was enhanced successfully
-
save
void save(String directoryName) throws IOException
Method to save the (current) class definition bytecode into a class file. Only has effect if the bytecode has been modified (by enhance()). If directoryName is specified it will be written to $directoryName/className.class else will overwrite the existing class.- Parameters:
directoryName- Name of a directory (or null to overwrite the class)- Throws:
IOException- If an I/O error occurs in the write.
-
getClassBytes
byte[] getClassBytes()
Access the class bytecode.- Returns:
- the class in byte array format
-
getPrimaryKeyClassBytes
byte[] getPrimaryKeyClassBytes()
Access the generated primary-key class bytecode.- Returns:
- the primary-key class in byte array format
-
getMetaDataManager
MetaDataManager getMetaDataManager()
Accessor for the MetaData manager in use.- Returns:
- MetaData manager
-
getClassLoaderResolver
ClassLoaderResolver getClassLoaderResolver()
Accessor for the ClassLoaderResolver in use.- Returns:
- ClassLoader resolver
-
getClassMetaData
ClassMetaData getClassMetaData()
Accessor for the ClassMetaData for the class.- Returns:
- MetaData for the class
-
setNamer
void setNamer(EnhancementNamer namer)
-
getNamer
EnhancementNamer getNamer()
-
getClassBeingEnhanced
Class getClassBeingEnhanced()
Accessor for the class being enhanced.- Returns:
- Class being enhanced
-
getClassName
String getClassName()
Accessor for the name of the class being enhanced.- Returns:
- Class name
-
getASMClassName
String getASMClassName()
Accessor for the ASM class name for the class being enhanced.- Returns:
- ASM class name
-
getClassDescriptor
String getClassDescriptor()
Accessor for the class descriptor for the class being enhanced- Returns:
- class descriptor
-
getMethodsList
List<ClassMethod> getMethodsList()
Accessor for the methods required.- Returns:
- List of methods required for enhancement
-
getFieldsList
List<ClassField> getFieldsList()
Accessor for the fields required.- Returns:
- List of fields required for enhancement
-
isPersistable
boolean isPersistable(String className)
Check if the class is Persistable or is going to be enhanced based on the metadata- Parameters:
className- the class name- Returns:
- true if Persistable
-
-