Hi Corey,The class must be loadable in order for OpenJPA to introspect it. So the classloader in which the class is created must first create it and then let OpenJPA enhance it.
In the application server interfaces there is a specific mechanism to allow the class to be loaded by a temporary class loader. If you look around in this code, you might find a way to define your dynamic class using a special class loader and then ask OpenJPA to use this class loader as input to enhance the class.
Applying this to the built-in transformer implementation might also be possible by changing the transform method. If you detect that the class does not exist, you could use a dynamically created class loader to create the class from the byte array and then use that class definition in the OpenJPA transform method.
Craig On Jan 23, 2008, at 12:17 AM, Patrick Linskey wrote:
Hi,It seems like it might be possible to cache enhanced bytecode by classname until after transformation and all classes are defined.It certainly should be possible, but currently, OpenJPA uses reflection to load a bunch of information about the class during enhancement. -Patrick On Jan 22, 2008 6:27 AM, Corey Klaasmeyer <[EMAIL PROTECTED]> wrote:I'm generating persistent classes at runtime which are transformed by the PCClassFileTransformer.transform(ClassLoader, String, Class, ProtectionDomain, byte[]) method. Unfortunately, the result of the BCClass.getType() passed as the first argument to the method MetaDataRepository.getMetaData(Class, ClassLoader, boolean) in PCEnhancer(OpenJPAConfiguration, BCClass, MetaDataRepository, ClassLoader) throws a ClassNotFoundException -- the transformer isattempting to load a class that is not defined, therefore not loadable, until transformation is complete. Is there some fundamental reason why the enhancer needs a reference to a defined class rather than just thebytecode?It seems like it might be possible to cache enhanced bytecode by classname until after transformation and all classes are defined. Corey-- Patrick Linskey 202 669 5907
Craig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:[EMAIL PROTECTED] P.S. A good JDO? O, Gasp!
smime.p7s
Description: S/MIME cryptographic signature
