• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Look up Method Injection in Spring

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

I'm trying something in the lines of having a Factory class return a Prototype of multiple types.

I have a Factory class as follows:



In the above getXXXPersistence() methods, I would like to have Spring give my objects as I have some injections happening in those implementations. For the very same purpose, I have looked up the Spring docs and came across the look up method injection. But the problem here is that to use the method injection (without having any dependencies on Spring, using the CGLIB proxy), I must declare the above Factory class as abstract as required by the CGLIB proxy. If that be the case, then it violates one principle that I want to maintain which is that the Factory class above will not retain its static methods and the class will not be final. Is there a way to overcome this?

In essence I want Spring to inject a Prototype bean (XXXPersistence) into the Singleton bean (MyXXXFactory). Any suggestions?
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But anyways, I wanted to give it a try. Here is how my first attempt looks like:

My PersistenceFactory:



In my Service layer I let Spring inject my PersistenceFactory as follows:




The error that I face:

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic