Results 1 to 4 of 4

Thread: Need help getting all filename strings

  1. #1
    Join Date
    Oct 2010
    Posts
    2

    Default Need help getting all filename strings

    Hello:

    Wondering if anyone can help us with this. We are using spring bat to iterate through all xml files in a directory. Unfortunately, we seem to be able to only get the first filename, and this is causing our logs to display the incorrect filename when there are multiple files to process.

    Here is the section causing us issues:

    Code:
          public void beforeStep(StepExecution stepExecution) {
                if(LOG.isInfoEnabled()){
                      LOG.info("Processor beforestep ");
                }
                ExecutionContext ecStep = stepExecution.getExecutionContext();
                if(!ecStep.isEmpty() && ecStep.containsKey("FOO_FILE")){
                      try{
                            setAmrFileName(ecStep.getString("FOO_FILE")); //this is the line we try to set the filename
                      }catch(ClassCastException exception){                  // however we only ever get the first one when multiple
                            if(LOG.isDebugEnabled()){                              // files exist
                                  LOG.debug(exception);
                            }
                      }
                }
          }
    If anyone could help us understand what we are doing wrong, it would be greatly appreciated.
    Last edited by kmspring; Oct 22nd, 2010 at 12:27 PM.

  2. #2
    Join Date
    Jul 2010
    Location
    USA
    Posts
    43

    Default

    I can help you in this.
    May I know what kind of job you are using and more about your scenario.
    What do you do after you get files?

  3. #3
    Join Date
    Oct 2010
    Posts
    2

    Default

    The purpose of the job is to process all xml files in a directory and then send emails based on the contents in the files.

    We have all that working with spring bat, the only remaining issue is that we can't seem to iterate through all the filenames in the directory. The object we are getting the file name from always has the first filename as its value. See the sample code i posted in the original message.

    I have attached the full class in case that helps. Thanks a lot for your help.
    Attached Files Attached Files

  4. #4
    Join Date
    Jul 2010
    Location
    USA
    Posts
    43

    Default

    Where did you set AMR_FILE property in ExecutionContext.
    Does your Reader return NotificationRec object? If so, was that Object created from one of the xml files you are using?

    For the similar scenario like this, I used MultiresourceItemReader which takes all the matching files with the given regex and iteratively reads records from each file.
    Each read record is return to Processor. Your processor could do business logic on records.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •