Search in sources :

Example 1 with InstantiationException

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);
    }
}
Also used : BeanContainer(org.hibernate.resource.beans.container.spi.BeanContainer) StrategySelector(org.hibernate.boot.registry.selector.spi.StrategySelector) ClassLoadingException(org.hibernate.boot.registry.classloading.spi.ClassLoadingException) InstantiationException(org.hibernate.InstantiationException) InstantiationException(org.hibernate.InstantiationException)

Aggregations

InstantiationException (org.hibernate.InstantiationException)1 ClassLoadingException (org.hibernate.boot.registry.classloading.spi.ClassLoadingException)1 StrategySelector (org.hibernate.boot.registry.selector.spi.StrategySelector)1 BeanContainer (org.hibernate.resource.beans.container.spi.BeanContainer)1