use of com.peterphi.std.guice.hibernate.module.ext.HibernateConfigurationValidator in project stdlib by petergeneric.
the class HibernateModule method getHibernateConfiguration.
@Provides
@Singleton
public Configuration getHibernateConfiguration(GuiceConfig guiceConfig, @Named(GuiceProperties.HIBERNATE_PROPERTIES) String propertyFileName, HibernateObservingInterceptor interceptor) {
final Properties properties = extractHibernateProperties(guiceConfig, propertyFileName);
validateHibernateProperties(guiceConfig, properties);
// Set up the hibernate Configuration
Configuration config = new Configuration();
// Set up the interceptor
config.setInterceptor(interceptor.getInterceptor());
config.addProperties(properties);
configure(config);
registerTypes(config);
{
ServiceLoader<HibernateConfigurationValidator> services = ServiceLoader.load(HibernateConfigurationValidator.class);
final Iterator<HibernateConfigurationValidator> it = services.iterator();
if (log.isTraceEnabled())
log.trace("Evaluate HibernateConfigurationValidators. has at least one=" + it.hasNext());
while (it.hasNext()) {
final HibernateConfigurationValidator validator = it.next();
if (log.isTraceEnabled())
log.trace("Validating hibernate configuration with " + validator);
// Have the validator check the hibernate/database configuration
validator.validate(config, properties, guiceConfig);
}
}
return config;
}
Aggregations