On Mar 27, 2006, at 6:42 PM, Bill Dudney wrote:
Jeff and I were at TSS Symposium last week and we had a chance to talk through the work for JPA. I wanted to get our thoughts into an email and off to the list so we are not duplicating work. We are planning on doing the mapping work. Jeff is going to tackle handling the annotations and I am going to handle parsing the orm.xml files and augmenting the mapping info.

...

3. Runtime - this would use JDK 1.5 java.lang.instrument API. On the one hand it is the least intrusive option, but on the other it requires a special runtime parameter (-javaagent:cayenne.jar).

Ideas, comments?


From my reading of the spec it looks like the ClassTransformer is there so that 3 does not require the special runtime parameter. Is there something that I'm missing? I am basing my assumptions on the comment (starting on page 148) on the addTransformer (ClassTransformer) method on the PersistenceUnitInfo class.

Thoughts welcome. Also if you are doing any of this work please speak up so we don't duplicate.


Excellent! Let's get it rolling. I'll send a separate email on the bytcode lib choices.

Regarding the ClassTransformer... JPA ClassTransformer is there to presumably hide the details of how the actual enhancement is done. By itself it won't allow you to redefine the class in the application ClassLoader, only in your own ClassLoader. Consider a test case:

   Object object = query.getSingleResult();

assertEquals("Test1", MyPersistentClass.class.getName(), object.getClass().getName());
   assertTrue("Test2", object instanceof MyPersistentClass);

The first test succeeds, but the second one fails! Cause you'll be checking against MyPersistentClass from the app ClassLoader, not the enhanced MyPersistentClass from the JPA ClassLoader. Somehow we need to make a ClassTransformer to be a "delegate" for the app class loader to force the entire application to use the enhanced version of the class. The only way I know of is the instrumentation API.

Andrus




Reply via email to