Spring destroyScopedBean?
I am using
configurableListableBeanFactory.destroyScopedB开发者_高级运维ean("MyForm")
to clear the MyForm bean from the session(it's a session scope spring bean).
After destroying the bean in the very next line I did,
MyForm myForm= (MyForm)configurableListableBeanFactory.getBean("MyForm");
I was expecting the myForm instance to be null but it's not instead it's still an object but all the instance members of MyForm are now null!
shouldn't the myForm object been completely removed from the session(thus becoming available for GC) instead of it's instance member's values changed to null?
Thanks
I think you'll find that getBean
has returned you a new instance of your form object, rather than the same object with its form fields cleared.
I was rather expecting that it'd throw an exception here, rather than return a new object, but this described behaviour does seem consistent with how scoped beans work.
The answer for my query is that,
applicationCOntext
is built on top of
beanFactory
, Once I have destroyed the scoped bean, and then I again query for that bean, so I am returned a new bean instance! :)
精彩评论