Controlling the order in which files get processed

Posted by [email protected] on Oracle Blogs See other posts from Oracle Blogs or by [email protected]
Published on Wed, 28 Apr 2010 07:22:36 +0000 Indexed on 2010/04/28 8:54 UTC
Read the original article Hit count: 240

Filed under:

The File/Ftp Adapter allows you to control the order in which files get processed. For example, you might want the files to be processed in order of their modified times/ file sizes etc.

Luckily, the File/Ftp adapters allow you to achieve this via a "FileSorter" attribute that you can define in the JCA file for your inbound File/Ftp Adapter service.

file_sorting.jpg

 

The File/Ftp Adapters ship with two predefined sorters that use the last modified times e.g.

 

file_sorting_timestamp.jpg

However, there are times when you would like to define the order yourself. In situations like this, you can implement a Java Comparator and register the comparator with the File Adapter as described below:

1) Write a comparator. For example, the FileSizeSorter comparator sorts the files in descending order of their sizes:

 

file_sorter_size.jpg

2) In order to compile this class though, you will need fileAdapter.jar in the classpath.

 

© Oracle Blogs or respective owner