
Originally Posted by
boekhold
Hi all,
What happens when my groovy source file changes now? What will happen to the beanA instance that's wired into beanB?
So, I decided to create a little test case (all written in groovy btw), and to my surprise this works as expected. I created an IoC container with a single beanA, which is written in groovy and has a single method "doit()" that just prints a message to stdout. Then a small test script creates a FileSystemXmlApplicationContext and does a getBean("beanA"). In a loop I then call beanA.doit().
To my surprise I could modify the script source for beanA, and it was picked up.
Based on this, I do believe that [i]somewhere[/] spring wraps a Proxy object around my groovy class. The proxy instance stays constant while the wrapped groovy class is 'swapped out' when the script source is modified. Another reason why I believe that is because at first I was getting a
Code:
java.lang.ClassCastException: sun.proxy.$Proxy5 cannot be cast to MainBean
exception if I just tried to call "beanA.doit()" from my groovy test script. I only got this working after I changed that to "beanA.invokeMethod("doit", null)".
Still, if anybody knows the final answer for this, I'd still be interested in an explanation on how this is *really* handled in spring.
Maarten