Re: JPA enhancer behavior - fat agent?

From: Dain Sundstrom (dai..q80.com)
Date: Thu Feb 22 2007 - 13:45:52 EST

  • Next message: Robert Zeigler: "more XMLMappingDescriptor woes. :)"

    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
    @Entity 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
    >



    This archive was generated by hypermail 2.0.0 : Thu Feb 22 2007 - 13:46:31 EST