in extscript-core-root/extscript-spring/src/main/java/org/apache/myfaces/extensions/scripting/spring/bean/support/CompilationAwareInstantiationStrategy.java [182:223]
public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner,
Object factoryBean, Method factoryMethod, Object[] args)
{
// The factory method which we'll use to instantiate the bean.
Method factoryMethodToUse = factoryMethod;
// Determine whether the given bean definition supports a refresh operation,
// i.e. if a refresh metadata attribute has been attached to it already.
//RefreshableBeanAttribute refreshableAttribute =
// (RefreshableBeanAttribute) beanDefinition.getAttribute(
// RefreshableBeanAttribute.REFRESHABLE_BEAN_ATTRIBUTE);
boolean refreshableAttribute = (beanDefinition.getBeanClass().getClassLoader() instanceof ThrowAwayClassloader);
if (refreshableAttribute)
{
factoryMethodToUse = (Method) beanDefinition.getAttribute(CACHED_FACTORY_METHOD);
if (factoryMethodToUse == null)
{
try
{
// Reload the factory methods to use. The problem is that the given factory method possibly
// references an outdated Class object, which means, that if we used the given factory method
// to instantiate another object, we would end up with a ClassCastException as the given
// factory bean has already been reloaded.
factoryMethodToUse = beanDefinition.getBeanClass().getMethod(
factoryMethod.getName(), factoryMethod.getParameterTypes());
// Cache the factory method so that we don't have to use reflection every time.
beanDefinition.setAttribute(CACHED_FACTORY_METHOD, factoryMethodToUse);
}
catch (NoSuchMethodException ex)
{
throw new BeanInstantiationException(
beanDefinition.getBeanClass(), "Couldn't reload the factory method '" + factoryMethod
+ "' to instantiate the bean '" + beanName + "' . Have you removed the required "
+ "factory method without updating the bean definition?", ex);
}
}
}
return super.instantiate(beanDefinition, beanName, owner, factoryBean, factoryMethodToUse, args);
}