Domanda

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?

È stato utile?

Soluzione

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

Yes, setter injection.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top