This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Spring and the fly likes Interface injection in Spring Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Spring
Reply Bookmark "Interface injection in Spring" Watch "Interface injection in Spring" New topic
Author

Interface injection in Spring

Manikandan Swaminathan
Ranch Hand

Joined: Aug 10, 2008
Posts: 115
Hi all,

I am new to Spring.

Can anyone of you please explain Interface Injection in Spring with a simple example?

Or is there any tutorial available for this?

I searched, but unable to find for interface injection in particular.

Have a great weekend !

Thanks
Eduardo Bueno
Ranch Hand

Joined: Jun 04, 2009
Posts: 154
A simple example:


And now you just need a reference of the SomeRepository interface which will be injected (by type, since SomeRepositoryImpl implements SomeRepository) via setter method:
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
Spring doesn't support Interface injection and the above example about autowiring is incorrect.
Will reply more later.


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Manikandan Swaminathan
Ranch Hand

Joined: Aug 10, 2008
Posts: 115
Hi Kengkaj,

Can you please post the details?

If possible please mail me the details. My mail id is graghuu@gmail.com

Thanks for your help !

Regards
Jaydeep Mazumdar
Greenhorn

Joined: Aug 26, 2009
Posts: 23
Spring does not fully support Interface injection although the same can be achieved using "autowire=byType". But this has some serious drawbacks. See this discussion for a proposed implementation of Interace injection in Spring:
http://opensource.atlassian.com/confluence/spring/display/DISC/Adding+Interface+Injection+to+Spring
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Interface injection in Spring
 
Similar Threads
What is the benefit of using Interface Injection?
Spring
Spring dependency injection
Is this an example of Dependency Injection?
Spring