Announcement Announcement Module
No announcement yet.
Retrieving resource name (filename) from a skipListener Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Retrieving resource name (filename) from a skipListener


    I am using a MultiResourceItemReader in order to read different files in a folder.

    Processing those files might involve an exception if one record is not correctly validated (using ValangValidator), those incorrect records are being handled with a listener in order to log the incorrect record in a database.

    Which is the best approach in order to retrieve the resource name (file name being processed) from the listener that handles the skipped records? I need to store the file name in the database with the incorrect record but i am not able to do that.

    I have seen that MultiResourceItemReader now contains a method called getCurrentResource() but i do not know how to retrieve that information from my "skipListener" class.

    I think that the following post explains the solution, but I do not know how to inject a MultiResourceItemReader into my FieldSetMapper:

    Thanks a lot for your help in advance.

  • #2
    but I do not know how to inject a MultiResourceItemReader into my FieldSetMapper
    that should be quite easy, see this pseudocode

    <bean id="mrir" class="...MultiResourceItemReader">
    <bean id="mapper" class="...CustomFieldSetMapper">
       <property name="mrir" ref ="mrir" />
    you just create a custom FieldSetMapper like this

    public class CustomFieldSetMapper implements FieldSetMapper<String> {
        private MultiResourceItemReader mrir;
        public String mapFieldSet(FieldSet fieldSet) throws BindException {
            String fileName = mrir.getCurrentResource().getFilename();
            return fieldSet.readString("foo");
        public void setMrir(MultiResourceItemReader mrir) {
            this.mrir = mrir;


    • #3
      Thanks a lot Michael!

      I was mixing a couple of concepts, but now they are clear and I have been able to do that.

      Thanks a lot again!