BBjFileSystem::watchDirectory

Description

In BBj 17.00 and higher, this method watches the specified directory for changes (create, modify, delete), periodically reporting any changes through the specified callback.

Syntax

Return Value Method

String

watchDirectory(String directory, String label)

String

watchDirectory(String directory, CustomObject customObj, String methodName)

String

watchDirectory(String directory, Object object, String methodName)

Parameters

Parameter Description
directory The directory to be watched.
label The subroutine to be invoked to report any directory changes.
customObj A CustomObject containing the method to be called to report any directory changes
methodName An Object containing the method to be called to report any directory changes.
object A Java Object containing the method to be called to report any directory changes

Return Value

Returns the full directory path.

Remarks

When registering a CustomObject method as the target of the callback, the method must conform to the following constraints:

  • The method must be declared as public with a return type of void.

  • The method must accept a single parameter.

The type of the method parameter must be either BBjDirectoryChangeEvent or BBjEvent or Object.

To stop watching a directory, see unwatchDirectory or unwatchAllDirectories.

Example

rem ' BBjFileSystem::watchDirectory

setesc eoj
fs! = bbjapi().getFileSystem()
print "watchDirectory ",fs!.watchDirectory(".","watch")
print "watchDirectory ",fs!.watchDirectory("..","watch")
process_events

eoj:
    rem ' unwatch individual directories
    fs!.unwatchDirectory(".")
    fs!.unwatchDirectory("..")

    rem ' or unwatch all of them at once
    fs!.unwatchAllDirectories()
release

watch:
    event! = bbjapi().getLastEvent()
    print event!.getEventName()," ",
    print event!.getDirectory()," ",
    print event!.getFilename()," ",
    print event!.getAction(),
    print event!.getChange()
return

ClosedVersion History

  • 25.03: Previously, this method could only accept a BBj CustomObject, but can now take any Java Object as a parameter.

See Also

BBjDirectoryChangeEvent

BBjFileSystem

BBjFileSystem::unwatchDirectory

BBjFileSystem::unwatchAllDirectories

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.