If an object is created by some other infrastructure, it makes it impossible to use Spring to inject dependencies.
For example, if I have class called Root which is automatically created by some other infrastructure and this class has a method setTrunk(), I cannot use Spring to call setTrunk because I cannot ask Spring to create Root (unless I can get access to Root after it's created using some singleton lookup I guess - but if I have to set it up as a singleton just for this purpose, it's not a clean design...).
Another example, if I have a JUnit test case with a settor setDataSource(), how can I use Spring to call setDataSource() if I run the test case through JUnit?
Is this problem statement accurate? If so, what are people doing to sidestep this problem in a clean way?
Thanks,
Ted


Reply With Quote