I have been reading many posts the past few days about whether you should use getBean() or not from your bean factory / application context. However I still have not seen any concrete example (or maybe my eyes just aren't seeing it) on how to avoid using getBean() from an app context / bean factory for at least one object. I have seen many examples of using Service Locators and other strategies but inevitably when they show the beans.xml or whatever they call it I never see how they get that one lonely bean into their application.
Quick background: Our app is a Java Swing / Command line application (no web stuff here). I would like to convert a large portion of our configuration base over to Spring IoC and move the coupling from inside the code to the configuration xml.
To start I will simply have a set of ContextGroups that will contain various Contexts within them. Other Pojo ojects will belong to these Contexts.
In this case my top level (container) object(s) are the set of ContextGroups. I see how to set up and build the bean definitions in the xml to mend everything together to produce this relationship but then there is still the issue of having my main() get a reference to one or more of these ContextGroups without doing beanFactory.getBean("myGroup");
I don't have a problem using one or two getBean() calls in my application. I figure I may have to as I am introducing Spring late into the architecture. However my curiosity and desire to learn is forcing me to ask : "How do you wire up your application to avoid calling getBean() at least once in your code"?
thanks in advance