use of org.hibernate.boot.spi.SessionFactoryBuilderFactory in project hibernate-orm by hibernate.
the class MetadataImpl method getSessionFactoryBuilder.
@Override
public SessionFactoryBuilder getSessionFactoryBuilder() {
final SessionFactoryBuilderImpl defaultBuilder = new SessionFactoryBuilderImpl(this);
final ClassLoaderService cls = metadataBuildingOptions.getServiceRegistry().getService(ClassLoaderService.class);
final java.util.Collection<SessionFactoryBuilderFactory> discoveredBuilderFactories = cls.loadJavaServices(SessionFactoryBuilderFactory.class);
SessionFactoryBuilder builder = null;
List<String> activeFactoryNames = null;
for (SessionFactoryBuilderFactory discoveredBuilderFactory : discoveredBuilderFactories) {
final SessionFactoryBuilder returnedBuilder = discoveredBuilderFactory.getSessionFactoryBuilder(this, defaultBuilder);
if (returnedBuilder != null) {
if (activeFactoryNames == null) {
activeFactoryNames = new ArrayList<>();
}
activeFactoryNames.add(discoveredBuilderFactory.getClass().getName());
builder = returnedBuilder;
}
}
if (activeFactoryNames != null && activeFactoryNames.size() > 1) {
throw new HibernateException("Multiple active SessionFactoryBuilderFactory definitions were discovered : " + StringHelper.join(", ", activeFactoryNames));
}
if (builder != null) {
return builder;
}
return defaultBuilder;
}
Aggregations