Difference between spring setter and interface injection?

Posted by Satish Pandey on Programmers See other posts from Programmers or by Satish Pandey
Published on 2012-08-31T15:31:11Z Indexed on 2012/09/01 21:49 UTC
Read the original article Hit count: 319

I know how constructor and setter injection works in spring.

Normally I use interfaces instead of classes to inject beans using setter and I consider it as interface injection, but in case of constructor we also use interfaces (I am confused). In following example I use JobProcessor interface instead of JobProcessorImpl class.

public class JobScheduler {
    // JobProcessor interface
    private JobProcessor jobProcessor;
    // Dependecy injection
    public void setJobProcessor(JobProcessor jobProcessor){
        this.jobProcessor = jobProcessor;
    }
}

I tried to find a solution by googling but there are different opinions by writers. Even some people says that spring doesn't support interface injection in their blogs/statements.

Can someone help me by example?

© Programmers or respective owner

Related posts about interfaces

Related posts about dependency-injection