[hibernate-dev] hibernate-osgi JPA bootstrap & classloader

Brett Meyer brmeyer at redhat.com
Thu May 28 15:04:11 EDT 2015


> > > Is that the best way to know when TransactionManagers and DataSources
> > come
> > > and go too?  Or is there a more specific concept for listening to an
> > "OSGi
> > > service"?
> >
> > At least for TransactionManagers, yes, the BundleListener is probably the
> > best approach.  I'm not aware of a more specific way beyond that, but I'm
> > not 100%.  Honestly not sure about the DataSource -- can't remember if most
> > containers automatically expose that or not.
> >
> 
> But I would have to know the bundle that TransactionManager comes from in
> order to listener to it, no?

Doable.  In OsgiServiceUtil, look at its use of ServiceTracker.  Instead of ServiceTracker#getServices, we'd use ServiceTracker#getServiceReferences.  From the returned ServiceReference, we can get both the actual service impl, as well as the Bundle that provides it.


More information about the hibernate-dev mailing list