On Nov 2, 2007, at 11:29 AM, Stephen Zack wrote:
Using the latest examples.jar, to set up a process to monitor
multiple file directories with FileMonitor (I spawned separate
FileMonitor instances), I encountered a problem that the class only
returns file events from the last monitored directory.
From eclipse, I noticed that the Kernel32 interface contains a
static FILE_NOTIFY_INFORMATION structure subclass. Could that be
reason I’m only seeing changes in one directory? (Should this
logically be a static element?)
Acknowledging that this is only an example class, is there an
easier way to fix this, short of writing an entirely new Kernel32
interface?
Thanks in advance for any assistance.
The "static"-ness of the class merely means that it does not have a
reference to an instance of the enclosing class; in this case it
allows the structure to be used independently of the interface, and
yet stay associated with that interface.
Yes it's only an example, but I think it's reasonable to expect it to
work for more than one directory entry. Chances are I made some
mistake in translating from the original W32 API example. One guess
would be that you might need to use a single IO completion port for
*all* dir entries, rather than setting up a new one for each
(glancing at the code now, I see there's a single "port" member, that
gets overwritten with each added file).
I'm happy to roll in fixes for this if you solve it; you should start
with a corresponding JUnit test that watches *two* files (the
existing test only looks at one...). I'm happy to take a look at it
further, but may not have time for a little while.
T.