It is not possible to use a ServiceContributor when using the OSGi boostrap via OsgiSessionFactoryService. The getService method:
@Override
public Object getService(Bundle requestingBundle, ServiceRegistration registration) {
osgiClassLoader.addBundle( requestingBundle );
return configuration.buildSessionFactory( serviceRegistry );
}
throws an org.hibernate.service.UnknownServiceException. This is due to the fact the contributor is not discovered via the Java Service Loader mechanism. OsgiSessionFactoryService should handle contributors in a similar fashion as integrators and look them up via the OSGi ServiceTracker.
Also, the code should add some error handling. Currently an exception seems to get just swallowed.
|