HHH-13696 Minor code refactoring and applying the Hibernate code style
This commit is contained in:
parent
051a7d9b7c
commit
02089a5cce
|
@ -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() );
|
||||
|
||||
ClassLoader prevCL = Thread.currentThread().getContextClassLoader();
|
||||
osgiClassLoader.addClassLoader( classLoader );
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue