Package org.datanucleus.enhancer
Interface ClassEnhancer
-
- All Known Implementing Classes:
ClassEnhancerImpl
public interface ClassEnhancer
Interface representation of an enhancer of a class.
-
-
Field Summary
Fields Modifier and Type Field Description static int
ASM_API_VERSION
Version of the ASM API to use (introduced in ASM v4 to aid backward compatibility).static String
OPTION_GENERATE_DEFAULT_CONSTRUCTOR
Option for generating the default constructor.static String
OPTION_GENERATE_DETACH_LISTENER
Option for use the detach listener.static String
OPTION_GENERATE_PK
Option for generating the default constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
enhance()
Method to enhance the class definition internally.String
getASMClassName()
Accessor for the ASM class name for the class being enhanced.Class
getClassBeingEnhanced()
Accessor for the class being enhanced.byte[]
getClassBytes()
Access the class bytecode.String
getClassDescriptor()
Accessor for the class descriptor for the class being enhancedClassLoaderResolver
getClassLoaderResolver()
Accessor for the ClassLoaderResolver in use.ClassMetaData
getClassMetaData()
Accessor for the ClassMetaData for the class.String
getClassName()
Accessor for the name of the class being enhanced.List<ClassField>
getFieldsList()
Accessor for the fields required.MetaDataManager
getMetaDataManager()
Accessor for the MetaData manager in use.List<ClassMethod>
getMethodsList()
Accessor for the methods required.EnhancementNamer
getNamer()
byte[]
getPrimaryKeyClassBytes()
Access the generated primary-key class bytecode.boolean
hasOption(String name)
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
save(String directoryName)
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 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
-
-