Y'all are talking about 2 different things:
-
container-managed JPA bootstrapping (e-OSGi)
-
Hibernate native boostrapping (SessionFactory) or application-managed JPA bootstrapping
Bram Pouwelse A PersistenceUnitInfo is built by the container and handed to the persistence provider only in container-managed JPA bootstrapping use cases. In that one use case, I agree with you and Christian Schneider that is seems like using just the PersistenceUnitInfo#getClassLoader would seem to make sense. But Christian Schneider, keep in mind that PersistenceUnitInfo and its javadocs were written by the JPA EG and that e-OSGi does not always comply with that. But if you are certain that Aries JPA properly defines PersistenceUnitInfo#getClassLoader, I think we should plan on using just that for this one case.
The second case is where the concept of "requesting bundle" comes into play. Christian Schneider that is term we have used for the bundle that requests persistence, aka the bundle that is the persistence unit. This is where what I laid out on the Karaf-user list comes into play. Here I think the BundleListener is needed. But maybe we should just "take a page" from the e-OSGi spec and simply shutdown the SF/EMF when the requesting-bundle goes away.
|