Question

I have a code containing the below snippet running:

class MyNewReader implements ItemReader<MyBean>, ItemStream{    
@Resource
SingleItemPeekableItemReader<MyBean> myBeanPeekableReader;

@Resource
public void setDelegate(MyJdbcReader myJdbcReader){
     myBeanPeekableReader.setDelegate(myJdbcReader);
}

I don't have any property delegate in my class MyNewReader. But still the annotation @Resource is working on setDelegate method and is working fine. Can someone tell that is it not necessary to have a property in the class to let annotation on setter method(having that property in its name) work...Is this not working as setter injection?

Was it helpful?

Solution

myBeanPeekableReader.setDelegate(myJdbcReader) gets its jdbcReader injected as parameter to the method you have annotated.

Yes, setter injection.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top