aspose file tools*
The moose likes Spring and the fly likes How to inject a factory through Spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "How to inject a factory through Spring" Watch "How to inject a factory through Spring" New topic

How to inject a factory through Spring

Anshul Chandra Saxena

Joined: Sep 10, 2009
Posts: 14

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.

Can anyone please let me know, how to do this.

Mark Spritzler

Joined: Feb 05, 2001
Posts: 17249

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.


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: How to inject a factory through Spring
Similar Threads
Injection - instance variable
What to choose, daoFactory or a SpringUtil from ZK?
Spring core container is the basis for complete Spring framework?
How to inject EntityManager via setter in spring
spring wont inject the entitymanager