use of org.hibernate.InstantiationException in project hibernate-orm by hibernate.
the class ManagedBeanRegistryInitiator method interpretExplicitBeanContainer.
private BeanContainer interpretExplicitBeanContainer(Object explicitSetting, ClassLoaderService classLoaderService, ServiceRegistryImplementor serviceRegistry) {
if (explicitSetting == null) {
return null;
}
if (explicitSetting instanceof BeanContainer) {
return (BeanContainer) explicitSetting;
}
// otherwise we ultimately need to resolve this to a class
final Class containerClass;
if (explicitSetting instanceof Class) {
containerClass = (Class) explicitSetting;
} else {
final String name = explicitSetting.toString();
// try the StrategySelector service
final Class selected = serviceRegistry.getService(StrategySelector.class).selectStrategyImplementor(BeanContainer.class, name);
if (selected != null) {
containerClass = selected;
} else {
containerClass = classLoaderService.classForName(name);
}
}
try {
return (BeanContainer) containerClass.newInstance();
} catch (Exception e) {
throw new InstantiationException("Unable to instantiate specified BeanContainer : " + containerClass.getName(), containerClass, e);
}
}
Aggregations