Module org.eclipse.persistence.core
Package org.eclipse.persistence.dynamic
Class DynamicClassLoader
java.lang.Object
java.lang.ClassLoader
org.eclipse.persistence.dynamic.DynamicClassLoader
- Direct Known Subclasses:
- DynamicRestClassLoader,- ReflectiveDynamicClassLoader,- XRDynamicClassLoader
This custom ClassLoader provides support for dynamically generating classes
 within an EclipseLink application using byte codes created using a
 
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.- Since:
- EclipseLink 1.2
- 
Nested Class SummaryNested Classes
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Map<String, EclipseLinkClassWriter> Map ofDynamicClassWriterused to dynamically create a class in thefindClass(String)call.Default writer to use if one is not specified.protected Map<String, DynamicClassLoader.EnumInfo> 
- 
Constructor SummaryConstructorsConstructorDescriptionDynamicClassLoader(ClassLoader delegate) Create a DynamicClassLoader providing the delegate loader and leaving the defaultWriter asDynamicClassWriterDynamicClassLoader(ClassLoader delegate, DynamicClassWriter writer) Create a DynamicClassLoader providing the delegate loader and a defaultDynamicClassWriter.
- 
Method SummaryModifier and TypeMethodDescriptionvoidRegister a class to be dynamically created using the defaultDynamicClassWriter.voidRegister a class to be dynamically created using a copy of defaultDynamicClassWriterbut specifying a different parent class.voidaddClass(String className, EclipseLinkClassWriter writer) Register a class to be dynamically created using the providedDynamicClassWriter.voidprotected Class<?> checkAssignable(Class<?> clz) voidcreateDynamicAdapter(String className) Create an adapter for givenclassNameClass<?> createDynamicClass(String className) Create a new dynamic entity type for the specified name assuming the use of the default writer and its default parent class.Class<?> createDynamicClass(String className, Class<?> parentClass) Create a new dynamic entity type for the specified name with the specified parent class.Class<?> createDynamicClass(String className, DynamicClassWriter writer) Create a dynamic class registering a writer and then forcing the provided class name to be loaded.voidcreateDynamicCollectionAdapter(String className) Create a collection adapter for givenclassNamevoidcreateDynamicReferenceAdapter(String className) Create a reference for givenclassNameprotected Class<?> defineDynamicClass(String name, byte[] b) Converts an array of bytes into an instance of classClass.protected Class<?> Create a new dynamic class if a ClassWriter is registered for the provided className.getClassWriter(String className) protected Map<String, EclipseLinkClassWriter> static DynamicClassLoaderLookup the DynamicConversionManager for the given session.Methods inherited from class java.lang.ClassLoaderclearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResource, findResources, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
- 
Field Details- 
classWritersMap ofDynamicClassWriterused to dynamically create a class in thefindClass(String)call. The application must register classes using addClass or createDynameClass prior to thefindClass(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. 
- 
enumInfoRegistry
- 
defaultWriterDefault writer to use if one is not specified.
 
- 
- 
Constructor Details- 
DynamicClassLoaderCreate a DynamicClassLoader providing the delegate loader and leaving the defaultWriter asDynamicClassWriter
- 
DynamicClassLoaderCreate a DynamicClassLoader providing the delegate loader and a defaultDynamicClassWriter.
 
- 
- 
Method Details- 
getDefaultWriter
- 
getClassWriters
- 
getClassWriter
- 
addEnum
- 
addClassRegister a class to be dynamically created using the defaultDynamicClassWriter.- See Also:
 
- 
addClassRegister a class to be dynamically created using a copy of defaultDynamicClassWriterbut specifying a different parent class.- See Also:
 
- 
addClassRegister a class to be dynamically created using the providedDynamicClassWriter. The registered writer is used when thefindClass(String)method is called back on this loader from theClassLoader.loadClass(String)call.If a duplicate request is made for the same className and the writers are not compatible a DynamicExceptionwill be thrown. If the duplicate request contains a compatible writer then the second request is ignored as the class may already have been generated.- Throws:
- DynamicException
- See Also:
 
- 
createDynamicClassCreate a dynamic class registering a writer and then forcing the provided class name to be loaded.
- 
checkAssignable
- 
createDynamicClassCreate a new dynamic entity type for the specified name assuming the use of the default writer and its default parent class.- See Also:
 
- 
createDynamicClassCreate a new dynamic entity type for the specified name with the specified parent class.- See Also:
 
- 
createDynamicAdapterCreate an adapter for givenclassName
- 
createDynamicCollectionAdapterCreate a collection adapter for givenclassName
- 
createDynamicReferenceAdapterCreate a reference for givenclassName
- 
findClassCreate a new dynamic class if a ClassWriter is registered for the provided className. This code is single threaded to ensure only one class is created for a given name and that the ClassWriter is removed afterwards.- Overrides:
- findClassin class- ClassLoader
- Throws:
- ClassNotFoundException
 
- 
defineDynamicClassConverts an array of bytes into an instance of classClass. Before theClasscan be used it must be resolved.
- 
lookupLookup the DynamicConversionManager for the given session. If the existing ConversionManager is not an instance of DynamicConversionManager then create a new one and replace the existing one.
 
-