Class DynamicClassLoader

  • Direct Known Subclasses:

    public class DynamicClassLoader
    extends ClassLoader
    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.
    dclarke, mnorman
    EclipseLink 1.2
    • Field Detail

      • classWriters

        protected Map<String,​EclipseLinkClassWriter> classWriters
        Map of 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.

      • defaultWriter

        public DynamicClassWriter defaultWriter
        Default writer to use if one is not specified.
    • Method Detail

      • addEnum

        public void addEnum​(String className,
                            Object... literalLabels)
      • createDynamicClass

        public Class<?> createDynamicClass​(String className,
                                           DynamicClassWriter writer)
        Create a dynamic class registering a writer and then forcing the provided class name to be loaded.
      • checkAssignable

        protected Class<?> checkAssignable​(Class<?> clz)
      • createDynamicAdapter

        public void createDynamicAdapter​(String className)
        Create an adapter for given className
        className -
      • createDynamicCollectionAdapter

        public void createDynamicCollectionAdapter​(String className)
        Create a collection adapter for given className
        className -
      • createDynamicReferenceAdapter

        public void createDynamicReferenceAdapter​(String className)
        Create a reference for given className
        className -
      • findClass

        protected Class<?> findClass​(String className)
                              throws ClassNotFoundException
        Create 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.
        findClass in class ClassLoader
      • defineDynamicClass

        protected Class<?> defineDynamicClass​(String name,
                                              byte[] b)
        Converts an array of bytes into an instance of class Class. Before the Class can be used it must be resolved.
        name -
        b -
      • lookup

        public static DynamicClassLoader lookup​(Session session)
        Lookup 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.
        session -