spring-batch icon indicating copy to clipboard operation
spring-batch copied to clipboard

Provide accessors in MongoItemWriter to facilitate extensions

Open vincendep opened this issue 3 years ago • 4 comments

Expected Behavior

Provide accessors for collection and delete properties of MongoItemWriter, so that would be easier extending the class

Current Behavior

MongoItemWriter doesn't provide accessors for collection and delete properties

Context

Currently the MongoItemWriter has an extension point in doWrite method. I encountered some difficulties implementing a custom "write or update" logic respecting the original contract, due to the fact that some private properties (collection and delete) don't provide an accessor method.

vincendep avatar Aug 12 '21 13:08 vincendep

Hello @vincendep. I'm wondering what exactly is what you need. Do you need a getter for those two fields or would you like to get protected fields for extending the class?.

santfirax avatar Aug 15 '21 18:08 santfirax

Hello @vincendep I have added a PR for this issue. @benas any chance that you can take a look at the PR? https://github.com/spring-projects/spring-batch/pull/3975

santfirax avatar Aug 15 '21 18:08 santfirax

Hello @santfirax. I don't know what is the best way to go, I just found a bit difficult to extend the MongoItemWriter. I thought about getters only because the one for the MongoTemplate is already provided

vincendep avatar Aug 15 '21 18:08 vincendep

Hi, I also have added PR ( #4148 ) for this issue. Similar discussion has been made for templete property in #1037, and resolved with PR #447 with commit cae2cabdce41ae9a67d4e469fb8b82ff4945a7d9. I did similar changes for this issue.

tolpp avatar Jul 07 '22 09:07 tolpp