public Object instantiate()

in extscript-core-root/extscript-spring/src/main/java/org/apache/myfaces/extensions/scripting/spring/bean/support/CompilationAwareInstantiationStrategy.java [78:110]


    public Object instantiate(
            RootBeanDefinition beanDefinition, String beanName, BeanFactory owner) throws BeansException
    {
        // Determine whether the given bean definition supports a refresh operation,
        // i.e. if a refresh metadata attribute has been attached to it already.
        boolean refreshableAttribute = (beanDefinition.getBeanClass().getClassLoader() instanceof ThrowAwayClassloader);
        if (refreshableAttribute)
        {
            // At this point the bean factory has already re-resolved the bean class, so it's safe
            // to use it. We don't have to care about whether it's the most recent Class object
            // at this point anymore.
            Constructor constructorToUse = null;
            Class classObj = beanDefinition.getBeanClass();
            if (classObj.isInterface())
            {
                throw new BeanInstantiationException(classObj, "Specified class is an interface");
            } else
            {
                try
                {
                    constructorToUse = classObj.getDeclaredConstructor((Class[]) null);
                }
                catch (Exception ex)
                {
                    throw new BeanInstantiationException(classObj, "No default constructor found", ex);
                }
            }
            return BeanUtils.instantiateClass(constructorToUse, null);
        } else
        {
            return super.instantiate(beanDefinition, beanName, owner);
        }
    }