what do you mean by requesting bundle? The bundle that creates the EntityManagerFactory?
Christian, Hibernate registers 2 ServiceFactories. The term "requesting bundle" comes from the parameters passed to the ServiceFactory... the bundle that s requesting the service, the "requesting service"
I made a distinction between app-managed when I discussed that Christian. So there are 3 cases here:
-
request a SessionFactory
-
request an EntityManagerFactory (non-managed)
-
request an EntityManagerFactory (managed)
In the first 2 cases really we should generally be using the ClassLoader from the requesting bundle. In the 3rd case, yes we should be using the PersistenceUnitInfo#getClassLoader. We agree on that 3rd case. I need to look at how the flow goes for requesting a managed EMF to see how we make that distinction between managed and non-managed.
As far as allowing users to specify which ClassLoader to use, Hibernate already has some hooks there. Let me look closer at the ServiceFactory contract and see the best way to allow that. I am not a fan of TCCL, especially considering the the flak Hibernate has taken form the OSGi community over its reliance on TCCL
I do still think that OsgiClassLoaderService currently has a design flaw in how it is used in hibernate-osgi. I'l try to discuss with Brett Meyer today.
|