PDA

View Full Version : Using FilenameFilter with FileSource



jonford
Jun 3rd, 2008, 05:44 AM
SI's FileSource supports the use of a FilenameFilter. Could anybody tell me how to inject a FilenameFilter if I create a file source using the following configuration?

<source-endpoint source="fileSource" channel="channel1">
<schedule period="10000"/>
</source-endpoint>
<file-source id="fileSource" type="text" directory="//input"/>

Many Thanks
Jon Ford

Mark Fisher
Jun 3rd, 2008, 06:00 AM
Namespace support is not currently available for those properties. However, I just created the following JIRA issue: http://jira.springframework.org/browse/INT-242

For now, to configure a fileFilter or filenameFilter, you would need to define the FileSource instance as a <bean/>. The id of that bean can still be used as a reference from the <source-endpoint/> element's "source" attribute.

Thanks,
Mark

jonford
Jun 3rd, 2008, 06:11 AM
I thought that was the answer.

Many thanks for your prompt reply.

Jon Ford.

Mark Fisher
Jun 3rd, 2008, 12:16 PM
Jon,

If you grab the latest version from SVN, the "file-filter" or "filename-filter" attributes may now be provided on a <file-source/> element (with a reference to a FileFilter or FilenameFilter instance respectively).

Thanks again for bringing this to our attention.

-Mark

jgaines
Jun 5th, 2008, 01:40 AM
We have many requirements for file sources which filter based on a regular expression against the file name. Typically we have many of these in a single integration context, so it would be great if we could write:



<file-source id="fileSource" type="text" directory="/input" filename-regex="rental*"/>
<file-source id="fileSource" type="text" directory="/input" filename-regex="sale*"/>
<file-source id="fileSource" type="text" directory="/input" filename-regex="disposal*"/>


ORO, which is already an SI dependency, provides three pre-baked FilenameFilter implementations in org.apache.oro.io which take their regex from a String: AwkFilenameFilter, GlobFilenameFilter and Perl5FilenameFilter.

What do you think of providing a regex attribute to file-source, and would it be reasonable to implement it with one of the ORO filters? I'll volunteer to code it as long as it's not a misguided idea :-).

Thanks,

Jerry Gaines

jgaines
Jun 9th, 2008, 09:05 PM
It seems that the idea of a filename-regex attribute is good, but it's better to do it without ORO. See issue INT-252 in Jira for more details.