When executing above code (plus some basic interfaces and FortuneServices, probably doesn't matter), I get the following output:
Inside CRICKET-COACH no-arg constructor
Inside CRICKET-COACH setter method Heavy weight bench presses
Not the best day it might be!
And here's the CricketCoach class:
Inside HelloSpringApp I am creating theCoach object from a "myCoach" bean that's configured inside .xml.
myCoach bean is tied to GymCoach.
Yet for some reason, those "debugging sysouts" are printed as well. From CricketCoach. Why would my program access CricketCoach class? Once again, inside .xml myCoach is tied to GymCoach; not to CricketCoach.
It has nothing to do with your myCoach bean. When Spring initialized, it creates all the beans you declared in your application context, so when lines 20-23 of your .xml file are processed, the CricketCoach constructor is invoked and the setFortuneService method is called to inject the service bean.
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck