+1 to what Dain says here. All the persistence providers that I'm
familiar with use the -javaagent on the java command line in Java SE
mode to do the instrumentation (bytecode enhancement) regardless of
the load order of the persistent classes and the persistence provider.
Craig
On Feb 22, 2007, at 10:45 AM, Dain Sundstrom wrote:
> You can't really push a class back into the app. Instead you must
> wait for the app to load (pull) a class and hook the load via the
> javaagent.
>
> In a managed (container) environment this works quite well because
> the container can guarantee that the JPA provider is full
> initialized before any app code is called. In an unmanaged
> environment life is much more difficult since it is by definition
> the application code that initializes the system. To get around
> this, you will need the javaagent to search for persistence units
> and determine which classes need to be enhanced. One nice thing,
> is most people will use the..ntity annotation instead of XML to
> declare their persistent beans, and this entity is easy to detect
> directly using asm. You should ask David Blevins about his xbean-
> finder code which is designed to detect such annotations.
>
> -dain
>
> On Feb 22, 2007, at 10:21 AM, Andrus Adamchik wrote:
>
>> I see how TemporaryClassLoader operates. We haven't been using
>> 'getNewTempClassLoader' in the provider code as of yet. Let me
>> poke around and see if I am overcomplicating the issue... I still
>> don't understand how to push an enhanced class back into the app
>> classloader space, but maybe I am wrong (still thinking in Cayenne
>> classic terms), and this is not needed.
>>
>> Andrus
>>
>>
>> On Feb 22, 2007, at 7:46 PM, Dain Sundstrom wrote:
>>> Sorry, got busy and missed this email.
>>>
>>> This is such a common problem, it was addressed directly by the
>>> JPA specs. When loading classes for inspection use the class
>>> loader returned from
>>> javax.persistence.spi.PersistenceUnitInfo.getNewTempClassLoader().
>>>
>>> For Cayenne's own PersistenceUnitInfo implementation, I suggest
>>> you copy org.apache.openejb.core.TemporaryClassLoader which I
>>> copied from OpenJPA and cleaned up.
>>>
>>> -dain
>>
>
Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russel..un.com
P.S. A good JDO? O, Gasp!
This archive was generated by hypermail 2.0.0 : Thu Feb 22 2007 - 20:23:10 EST