* @param integrationSettings Any integration settings passed by the EE container or SE application
*
* @return The built BootstrapServiceRegistry
*/
private BootstrapServiceRegistry buildBootstrapServiceRegistry(Map integrationSettings) {
final BootstrapServiceRegistryBuilder bootstrapServiceRegistryBuilder = new BootstrapServiceRegistryBuilder();
bootstrapServiceRegistryBuilder.with( new JpaIntegrator() );
final IntegratorProvider integratorProvider = (IntegratorProvider) integrationSettings.get( INTEGRATOR_PROVIDER );
if ( integratorProvider != null ) {
for ( Integrator integrator : integratorProvider.getIntegrators() ) {
bootstrapServiceRegistryBuilder.with( integrator );
}
}
final StrategyRegistrationProviderList strategyRegistrationProviderList
= (StrategyRegistrationProviderList) integrationSettings.get( STRATEGY_REGISTRATION_PROVIDERS );
if ( strategyRegistrationProviderList != null ) {
for ( StrategyRegistrationProvider strategyRegistrationProvider : strategyRegistrationProviderList
.getStrategyRegistrationProviders() ) {
bootstrapServiceRegistryBuilder.withStrategySelectors( strategyRegistrationProvider );
}
}
// TODO: If providedClassLoader is present (OSGi, etc.) *and*
// an APP_CLASSLOADER is provided, should throw an exception or
// warn?
ClassLoader classLoader;
ClassLoader appClassLoader = (ClassLoader) integrationSettings.get( org.hibernate.cfg.AvailableSettings.APP_CLASSLOADER );
if ( providedClassLoader != null ) {
classLoader = providedClassLoader;
}
else if ( appClassLoader != null ) {
classLoader = appClassLoader;
integrationSettings.remove( org.hibernate.cfg.AvailableSettings.APP_CLASSLOADER );
}
else {
classLoader = persistenceUnit.getClassLoader();
}
bootstrapServiceRegistryBuilder.with( classLoader );
return bootstrapServiceRegistryBuilder.build();
}