public class DynamicClassWriter extends Object implements EclipseLinkClassWriter
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()
and
DynamicClassLoader.defaultWriter
for the life of the class loader so
it is important that no unnecessary state be maintained that may effect
memory usage.
Modifier and Type | Field and Description |
---|---|
protected static String |
CLINIT |
protected static String |
DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES |
static int[] |
ICONST |
protected static String |
INIT |
protected Class<?> |
parentClass |
protected String |
parentClassName
Name of parent class.
|
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addFields(org.eclipse.persistence.internal.libraries.asm.ClassWriter cw,
String parentClassType)
Allow subclasses to add additional state to the dynamic entity.
|
protected void |
addInterface(String intf)
Allow subclasses to add additional interfaces to the dynamic entity.
|
protected void |
addMethods(org.eclipse.persistence.internal.libraries.asm.ClassWriter cw,
String parentClassType)
Allow subclasses to add additional methods to the dynamic entity.
|
protected DynamicClassWriter |
createCopy(Class<?> parentClass)
Create a copy of this
DynamicClassWriter but with a different
parent class. |
protected byte[] |
createEnum(DynamicClassLoader.EnumInfo enumInfo) |
protected String[] |
getInterfaces()
Interfaces the dynamic entity class implements.
|
Class<?> |
getParentClass() |
String |
getParentClassName() |
boolean |
isCompatible(EclipseLinkClassWriter writer)
Verify that the provided writer is compatible with the current writer.
|
String |
toString() |
protected boolean |
verify(Class<?> dynamicClass,
ClassLoader loader)
Verify that the provided class meets the requirements of the writer.
|
byte[] |
writeClass(DynamicClassLoader loader,
String className) |
protected static final String DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES
protected static final String INIT
protected static final String CLINIT
protected Class<?> parentClass
protected String parentClassName
public static int[] ICONST
public DynamicClassWriter()
public DynamicClassWriter(Class<?> parentClass)
public DynamicClassWriter(String parentClassName)
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.
public Class<?> getParentClass()
getParentClass
in interface EclipseLinkClassWriter
public String getParentClassName()
getParentClassName
in interface EclipseLinkClassWriter
public byte[] writeClass(DynamicClassLoader loader, String className) throws ClassNotFoundException
writeClass
in interface EclipseLinkClassWriter
ClassNotFoundException
protected void addInterface(String intf)
intf
- additional interfaceprotected void addFields(org.eclipse.persistence.internal.libraries.asm.ClassWriter cw, String parentClassType)
cw
- parentClassType
- protected void addMethods(org.eclipse.persistence.internal.libraries.asm.ClassWriter cw, String parentClassType)
cw
- parentClassType
- protected byte[] createEnum(DynamicClassLoader.EnumInfo enumInfo)
protected boolean verify(Class<?> dynamicClass, ClassLoader loader) throws ClassNotFoundException
DynamicClassWriter
this will ensure that the class is
a subclass of the parentClass
dynamicClass
- ClassNotFoundException
protected String[] getInterfaces()
protected DynamicClassWriter createCopy(Class<?> parentClass)
DynamicClassWriter
but with a different
parent class.public boolean isCompatible(EclipseLinkClassWriter 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.
isCompatible
in interface EclipseLinkClassWriter
Copyright © 2007–2021 Eclipse.org - EclipseLink Project. All rights reserved.