[Index]

file-watch


Provide a service for subscribers to watch a file system for Files existing, being created or being modified.

If the file is created during subscription the consumer may receive a notification for the same file twice. Once the subscription has succeeded a consumer should receive every creation and modification happening to the file.

If this service is stopped no notification is sent to consumers. Consumers must use the state of this service to know that it has stopped.

Consumers will receive creation and modification events on a different thread to the initial event if the file exists.

Implementation Note: This facility is still a work in progress. Requiring this service in a configuration is messy. In future releases this service should be hidden from users.


Property Summary

filter Provide a regular expression filter on the directory to reduce the stream of events.
kinds Kinds of events to watch, as specified by the Standard Watch Event Kinds, Either ENTRY_CREATE or ENTRY_MODIFY.
name The name of this service.
numberOfConsumers  
paths  
to  

Example Summary

Example 1 Trigger when two files arrive.

Property Detail

filter

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

Provide a regular expression filter on the directory to reduce the stream of events.

kinds

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

Kinds of events to watch, as specified by the Standard Watch Event Kinds, Either ENTRY_CREATE or ENTRY_MODIFY. Note that ENTRY_DELETE will not work in the current implementation.

name

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

The name of this service.

numberOfConsumers

AccessREAD_ONLY

paths

Configured ByELEMENT
AccessREAD_WRITE

to

Configured ByELEMENT
AccessREAD_WRITE


Examples

Example 1

Trigger when two files arrive.

<oddjob>
    <job>
        <sequential>
            <jobs>
                <mkdir dir="${some.dir}/etc" name="Create Test Dir"/>
                <file-watch id="file-watch" kinds="ENTRY_CREATE"/>
                <events:when id="both-files" name="When Both Files" xmlns:events="oddjob:events">
                    <jobs>
                        <events:list eventOperator="ALL">
                            <of>
                                <events:watch name="Watch File 1">
                                    <eventSource>
                                        <events:file>
                                            <fileWatch>
                                                <value value="${file-watch}"/>
                                            </fileWatch>
                                            <file>
                                                <value value="${some.dir}/file1.txt"/>
                                            </file>
                                        </events:file>
                                    </eventSource>
                                </events:watch>
                                <events:watch name="Watch File 2">
                                    <eventSource>
                                        <events:file>
                                            <fileWatch>
                                                <value value="${file-watch}"/>
                                            </fileWatch>
                                            <file>
                                                <value value="${some.dir}/file2.txt"/>
                                            </file>
                                        </events:file>
                                    </eventSource>
                                </events:watch>
                            </of>
                        </events:list>
                        <echo id="task">
                            ${both-files.trigger.ofs}
                        </echo>
                    </jobs>
                </events:when>
                <folder>
                    <jobs>
                        <copy id="createFile1" name="Create File 1" to="${some.dir}/file1.txt">
                            <input>
                                <buffer>
                                    Test1
                                </buffer>
                            </input>
                        </copy>
                        <copy id="createFile2" name="Create File 2" to="${some.dir}/file2.txt">
                            <input>
                                <buffer>
                                    Test2
                                </buffer>
                            </input>
                        </copy>
                        <delete name="Delete All Test Files">
                            <files>
                                <files files="${some.dir}/*"/>
                            </files>
                        </delete>
                    </jobs>
                </folder>
            </jobs>
        </sequential>
    </job>
</oddjob>


(c) R Gordon Ltd 2005 - Present