views:

83

answers:

1

Working on a large size project, we started to use spring to manage our dependency injection. Since most dev are migrate from coding stateful class, we found some of stateless bean actually contain instance variables which themself are stateful.

Correct me if I am wrong, it shouldn't be too tough to write a unit test to verify that all the stateless bean defined in spring xml actually is stateless (i.e. bean shouldn't have any instance variable which never defined in spring xml). Before I will try myself to write one, wonder if there is any existing tool out there to check that?

Thx

+1  A: 

Check out spring context analyzer. It detects a few of the common spring scope/wiring mistakes, including missing scope proxies and suspicious post-construct field state in your beans. I know many projects have been saved by it ;)

krosenvold