aspose file tools*
The moose likes Spring and the fly likes Interface injection in Spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
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: 117
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: 155
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: 117
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://aspose.com/file-tools
 
subject: Interface injection in Spring
 
Similar Threads
Spring
Spring dependency injection
Spring
Is this an example of Dependency Injection?
What is the benefit of using Interface Injection?