Package org.datanucleus.enhancer
Interface ClassEnhancer
- All Known Implementing Classes:
ClassEnhancerImpl
public interface ClassEnhancer
Interface representation of an enhancer of a class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Version of the ASM API to use (introduced in ASM v4 to aid backward compatibility).static final String
Option for generating the default constructor.static final String
Option for use the detach listener.static final String
Option for generating the default constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
enhance()
Method to enhance the class definition internally.Accessor for the ASM class name for the class being enhanced.Accessor for the class being enhanced.byte[]
Access the class bytecode.Accessor for the class descriptor for the class being enhancedAccessor for the ClassLoaderResolver in use.Accessor for the ClassMetaData for the class.Accessor for the name of the class being enhanced.Accessor for the fields required.Accessor for the MetaData manager in use.Accessor for the methods required.getNamer()
byte[]
Access the generated primary-key class bytecode.boolean
Accessor for whether a particular option is enabled.boolean
isPersistable
(String className) Check if the class is Persistable or is going to be enhanced based on the metadatavoid
Method to save the (current) class definition bytecode into a class file.void
setNamer
(EnhancementNamer namer) void
setOptions
(Collection<String> options) Method to set the options controlling the enhancement.boolean
validate()
Validate whether the class is enhanced.
-
Field Details
-
ASM_API_VERSION
static final int ASM_API_VERSIONVersion of the ASM API to use (introduced in ASM v4 to aid backward compatibility).- See Also:
-
OPTION_GENERATE_DEFAULT_CONSTRUCTOR
Option for generating the default constructor.- See Also:
-
OPTION_GENERATE_PK
Option for generating the default constructor.- See Also:
-
OPTION_GENERATE_DETACH_LISTENER
Option for use the detach listener.- See Also:
-
-
Method Details
-
setOptions
Method to set the options controlling the enhancement.- Parameters:
options
- The options
-
hasOption
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
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
-
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
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
-