This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have a main class, that receives an action from the jsp. On the basis of action value i need to invoke the correct service. I have adopted the Abstract Factory Pattern, wherein on the basis of action value, the correct service is invoked. My only problem is how to inject this factory into the main class using Spring.
There are Factory classes that you can create in Spring that can create instances for that class to inject. All you have to do is implement the FactoryBean interface. This way your instances can also be set to prototype, so that you get a new instance each time.