|
From: David B. <viv...@gm...> - 2005-12-01 15:49:31
|
I was looking at the script support in the sandbox and trying to get it to
work. It looks like the structure around AutoProxy-ing has changed its
structure quite a bit since this sandbox code was written.
In particular, the following line of code is in
AbstractAutowireCapableBeanFactory.createBean. Since the scripts are
created using factory methods, they don't have a class, and never run
through the BeanPostProcessor.
// Give BeanPostProcessors a chance to return a proxy instead of th=
e
target bean instance.
if (mergedBeanDefinition.hasBeanClass()) {
bean =3D applyBeanPostProcessorsBeforeInstantiation(
mergedBeanDefinition.getBeanClass(), beanName);
if (bean !=3D null) {
return bean;
}
}
Later in the same method, after the bean is instantiated, I inserted the
following code:
bean =3D instanceWrapper.getWrappedInstance();
if (!mergedBeanDefinition.hasBeanClass()) {
Object altBean =3D applyBeanPostProcessorsBeforeInstantiati=
on(
bean.getClass(), beanName);
if (altBean !=3D null) {
return altBean;
}
}
Yes, this is a big semantic violation to call a "beforeInstantiation" metho=
d
*after* instantiation. However, this, plus a few changes in the sandbox,
gets the Groovy support code to pass most of its tests! Any ideas?
Related to all this, I'm a bit surprised that the dynamic script
functionality has been dormant in the sandbox for so long. Am I the only
one who thinks this would be a powerful feature? Especially for creating
test stubs. Are other people using scripting support with Spring in
different ways?
|