public class DynamicClassLoader
extends java.lang.ClassLoader
DynamicClassWriter
. A DynamicClassLoader requires a parent or
delegate class-loader which is provided to the constructor. This delegate
class loader handles the lookup and storage of all created classes.Modifier and Type | Class and Description |
---|---|
static class |
DynamicClassLoader.EnumInfo |
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,EclipseLinkClassWriter> |
classWriters
Map of
DynamicClassWriter used to dynamically create a class in
the findClass(String) call. |
DynamicClassWriter |
defaultWriter
Default writer to use if one is not specified.
|
protected java.util.Map<java.lang.String,DynamicClassLoader.EnumInfo> |
enumInfoRegistry |
Constructor and Description |
---|
DynamicClassLoader(java.lang.ClassLoader delegate)
Create a DynamicClassLoader providing the delegate loader and leaving the
defaultWriter as
DynamicClassWriter |
DynamicClassLoader(java.lang.ClassLoader delegate,
DynamicClassWriter writer)
Create a DynamicClassLoader providing the delegate loader and a default
DynamicClassWriter . |
Modifier and Type | Method and Description |
---|---|
void |
addClass(java.lang.String className)
Register a class to be dynamically created using the default
DynamicClassWriter . |
void |
addClass(java.lang.String className,
java.lang.Class<?> parentClass)
Register a class to be dynamically created using a copy of default
DynamicClassWriter but specifying a different parent class. |
void |
addClass(java.lang.String className,
EclipseLinkClassWriter writer)
Register a class to be dynamically created using the provided
DynamicClassWriter . |
void |
addEnum(java.lang.String className,
java.lang.Object... literalLabels) |
protected java.lang.Class<?> |
checkAssignable(java.lang.Class<?> clz) |
java.lang.Class<?> |
createDynamicClass(java.lang.String className)
Create a new dynamic entity type for the specified name assuming the use
of the default writer and its default parent class.
|
java.lang.Class<?> |
createDynamicClass(java.lang.String className,
java.lang.Class<?> parentClass)
Create a new dynamic entity type for the specified name with the
specified parent class.
|
java.lang.Class<?> |
createDynamicClass(java.lang.String className,
DynamicClassWriter writer)
Create a dynamic class registering a writer and then forcing the provided
class name to be loaded.
|
protected java.lang.Class<?> |
defineDynamicClass(java.lang.String name,
byte[] b)
Converts an array of bytes into an instance of class Class.
|
protected java.lang.Class<?> |
findClass(java.lang.String className)
Create a new dynamic class if a ClassWriter is registered for the
provided className.
|
EclipseLinkClassWriter |
getClassWriter(java.lang.String className) |
protected java.util.Map<java.lang.String,EclipseLinkClassWriter> |
getClassWriters() |
DynamicClassWriter |
getDefaultWriter() |
static DynamicClassLoader |
lookup(Session session)
Lookup the DynamicConversionManager for the given session.
|
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
protected java.util.Map<java.lang.String,EclipseLinkClassWriter> classWriters
DynamicClassWriter
used to dynamically create a class in
the findClass(String)
call. The application must register
classes using addClass or createDynameClass prior to the
findClass(String)
being invoked.
The map of writers is maintained for the life of this DynamicClassLoader instance to ensure additional requests to create dynamic classes of the same name are properly verified. Duplicate requests for dynamic classes of the same name, same writer type, and the same parent class are permitted but different parent classes or different writer types are not.
protected java.util.Map<java.lang.String,DynamicClassLoader.EnumInfo> enumInfoRegistry
public DynamicClassWriter defaultWriter
public DynamicClassLoader(java.lang.ClassLoader delegate)
DynamicClassWriter
public DynamicClassLoader(java.lang.ClassLoader delegate, DynamicClassWriter writer)
DynamicClassWriter
.public DynamicClassWriter getDefaultWriter()
protected java.util.Map<java.lang.String,EclipseLinkClassWriter> getClassWriters()
public EclipseLinkClassWriter getClassWriter(java.lang.String className)
public void addEnum(java.lang.String className, java.lang.Object... literalLabels)
public void addClass(java.lang.String className)
DynamicClassWriter
.addClass(String, EclipseLinkClassWriter)
public void addClass(java.lang.String className, java.lang.Class<?> parentClass)
DynamicClassWriter
but specifying a different parent class.addClass(String, EclipseLinkClassWriter)
public void addClass(java.lang.String className, EclipseLinkClassWriter writer) throws DynamicException
DynamicClassWriter
. The registered writer is used when the
findClass(String)
method is called back on this loader from the
ClassLoader.loadClass(String)
call.
If a duplicate request is made for the same className and the writers are
not compatible a DynamicException
will be thrown. If the
duplicate request contains a compatible writer then the second request is
ignored as the class may already have been generated.
DynamicException
findClass(String)
public java.lang.Class<?> createDynamicClass(java.lang.String className, DynamicClassWriter writer)
protected java.lang.Class<?> checkAssignable(java.lang.Class<?> clz)
public java.lang.Class<?> createDynamicClass(java.lang.String className)
public java.lang.Class<?> createDynamicClass(java.lang.String className, java.lang.Class<?> parentClass)
protected java.lang.Class<?> findClass(java.lang.String className) throws java.lang.ClassNotFoundException
findClass
in class java.lang.ClassLoader
java.lang.ClassNotFoundException
protected java.lang.Class<?> defineDynamicClass(java.lang.String name, byte[] b)
name
- b
- java.lang.ClassFormatError
public static DynamicClassLoader lookup(Session session)
session
-