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 java.lang.StringOPTION_GENERATE_DEFAULT_CONSTRUCTOROption for generating the default constructor.static java.lang.StringOPTION_GENERATE_DETACH_LISTENEROption for use the detach listener.static java.lang.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.java.lang.StringgetASMClassName()Accessor for the ASM class name for the class being enhanced.java.lang.ClassgetClassBeingEnhanced()Accessor for the class being enhanced.byte[]getClassBytes()Access the class bytecode.java.lang.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.java.lang.StringgetClassName()Accessor for the name of the class being enhanced.java.util.List<ClassField>getFieldsList()Accessor for the fields required.MetaDataManagergetMetaDataManager()Accessor for the MetaData manager in use.java.util.List<ClassMethod>getMethodsList()Accessor for the methods required.EnhancementNamergetNamer()byte[]getPrimaryKeyClassBytes()Access the generated primary-key class bytecode.booleanhasOption(java.lang.String name)Accessor for whether a particular option is enabled.booleanisPersistable(java.lang.String className)Check if the class is Persistable or is going to be enhanced based on the metadatavoidsave(java.lang.String directoryName)Method to save the (current) class definition bytecode into a class file.voidsetNamer(EnhancementNamer namer)voidsetOptions(java.util.Collection<java.lang.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 java.lang.String OPTION_GENERATE_DEFAULT_CONSTRUCTOR
Option for generating the default constructor.- See Also:
- Constant Field Values
-
OPTION_GENERATE_PK
static final java.lang.String OPTION_GENERATE_PK
Option for generating the default constructor.- See Also:
- Constant Field Values
-
OPTION_GENERATE_DETACH_LISTENER
static final java.lang.String OPTION_GENERATE_DETACH_LISTENER
Option for use the detach listener.- See Also:
- Constant Field Values
-
-
Method Detail
-
setOptions
void setOptions(java.util.Collection<java.lang.String> options)
Method to set the options controlling the enhancement.- Parameters:
options- The options
-
hasOption
boolean hasOption(java.lang.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(java.lang.String directoryName) throws java.io.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:
java.io.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
java.lang.Class getClassBeingEnhanced()
Accessor for the class being enhanced.- Returns:
- Class being enhanced
-
getClassName
java.lang.String getClassName()
Accessor for the name of the class being enhanced.- Returns:
- Class name
-
getASMClassName
java.lang.String getASMClassName()
Accessor for the ASM class name for the class being enhanced.- Returns:
- ASM class name
-
getClassDescriptor
java.lang.String getClassDescriptor()
Accessor for the class descriptor for the class being enhanced- Returns:
- class descriptor
-
getMethodsList
java.util.List<ClassMethod> getMethodsList()
Accessor for the methods required.- Returns:
- List of methods required for enhancement
-
getFieldsList
java.util.List<ClassField> getFieldsList()
Accessor for the fields required.- Returns:
- List of fields required for enhancement
-
isPersistable
boolean isPersistable(java.lang.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
-
-