HHH-13696 Minor code refactoring and applying the Hibernate code style

This commit is contained in:
Sanne Grinovero 2019-10-28 10:53:51 +00:00
parent 051a7d9b7c
commit 02089a5cce
1 changed files with 7 additions and 6 deletions

View File

@ -85,21 +85,22 @@ public class OsgiPersistenceProvider extends HibernatePersistenceProvider {
final Map settings = generateSettings( properties );
// OSGi ClassLoaders must implement BundleReference
final ClassLoader classLoader = info.getClassLoader();
settings.put(
org.hibernate.cfg.AvailableSettings.SCANNER,
new OsgiScanner( ( (BundleReference) info.getClassLoader() ).getBundle() )
new OsgiScanner( ( (BundleReference) classLoader).getBundle() )
);
osgiClassLoader.addClassLoader( info.getClassLoader() );
osgiClassLoader.addClassLoader( classLoader );
ClassLoader prevCL = Thread.currentThread().getContextClassLoader();
final ClassLoader prevCL = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(info.getClassLoader());
Thread.currentThread().setContextClassLoader( classLoader );
return Bootstrap.getEntityManagerFactoryBuilder( info, settings,
new OSGiClassLoaderServiceImpl( osgiClassLoader, osgiServiceUtil ) ).build();
}
finally {
Thread.currentThread().setContextClassLoader(prevCL);
Thread.currentThread().setContextClassLoader( prevCL );
}
}