Class DynamicClassWriter
- java.lang.Object
-
- org.eclipse.persistence.dynamic.DynamicClassWriter
-
- All Implemented Interfaces:
EclipseLinkClassWriter
public class DynamicClassWriter extends Object implements EclipseLinkClassWriter
Write the byte codes of a dynamic entity class. The class writer will create the byte codes for a dynamic class that subclasses any provided class replicating its constructors and writeReplace method (if one exists).The intent is to provide a common writer for dynamic JPA entities but also allow for subclasses of this to be used in more complex writing situations such as SDO and DBWS.
Instances of this class and any subclasses are maintained within the
DynamicClassLoader.getClassWriters()
andDynamicClassLoader.defaultWriter
for the life of the class loader so it is important that no unnecessary state be maintained that may effect memory usage.- Since:
- EclipseLink 1.2
- Author:
- dclarke, mnorman
-
-
Field Summary
Fields Modifier and Type Field Description static int[]
ICONST
-
Constructor Summary
Constructors Constructor Description DynamicClassWriter()
DynamicClassWriter(Class<?> parentClass)
DynamicClassWriter(String parentClassName)
Create using a loader and class name so that the parent class can be lazily loaded when the writer is used to generate a dynamic class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<?>
getParentClass()
String
getParentClassName()
boolean
isCompatible(EclipseLinkClassWriter writer)
Verify that the provided writer is compatible with the current writer.String
toString()
byte[]
writeClass(DynamicClassLoader loader, String className)
-
-
-
Constructor Detail
-
DynamicClassWriter
public DynamicClassWriter()
-
DynamicClassWriter
public DynamicClassWriter(Class<?> parentClass)
-
DynamicClassWriter
public DynamicClassWriter(String parentClassName)
Create using a loader and class name so that the parent class can be lazily loaded when the writer is used to generate a dynamic class.The loader must not be null and the parentClassName must not be null and not an empty String. The parentClassName will be converted to a class using the provided loader lazily.
-
-
Method Detail
-
getParentClass
public Class<?> getParentClass()
- Specified by:
getParentClass
in interfaceEclipseLinkClassWriter
-
getParentClassName
public String getParentClassName()
- Specified by:
getParentClassName
in interfaceEclipseLinkClassWriter
-
writeClass
public byte[] writeClass(DynamicClassLoader loader, String className) throws ClassNotFoundException
- Specified by:
writeClass
in interfaceEclipseLinkClassWriter
- Throws:
ClassNotFoundException
-
isCompatible
public boolean isCompatible(EclipseLinkClassWriter writer)
Verify that the provided writer is compatible with the current writer. Returning true means that the bytes that would be created using this writer are identical with what would come from the provided writer.Used in
DynamicClassLoader.addClass(String, EclipseLinkClassWriter)
to verify if a duplicate request of the same className can proceed and return the same class that may already exist.- Specified by:
isCompatible
in interfaceEclipseLinkClassWriter
-
-