سؤال

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?

هل كانت مفيدة؟

المحلول

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

Yes, setter injection.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top