LibraryLink ToToggle FramesPrintFeedback

File Filtering

When a poller endpoint is configured to poll a directory it will attempt to consume any file placed into that directory. If you want to limit the files a poller endpoint will attempt to consume, you can configure the endpoint to filter files based on their names. To do so, you must supply the endpoint with an implementation of the java.io.FileFilter interface.

There are several file filter implementation available in open source including the Apache Commons IO implementations and the Apache Jakarta-ORO implementations. You can also implement your own file filter if you need specific filtering capabilities.

To implement a file filter you need to provide and implementation of the java.io.FileFilter interface. The FileFilter interface has a single method, accept() that needs to be implemented. Example 2.11 shows the signature of the accept() method.


The accept() method takes a File object that represents the file being checked against the filter. If the file passes the filter, the accept() method should return true. If the file does not pass, then the method should return false.

Example 2.12 shows a file filter implementation that matches against a string passed into its constructor.


You configure a poller endpoint to use a file filter using its filter attribute. The filter attribute's value is a reference to a bean element specifying the class of the file filter implementation.

Example 2.13 shows configuration for a poller endpoint that uses the file filter implemented in Example 2.11. The constructor-arg element sets the filter's fitlername by passing a value into the constructor.


[Note]Note

You can also configure a poller endpoint to use a file filter by adding a child filter element to the endpoint's configuration. The filter element simply wraps the bean element that configures the file filter.