Thanks for the suggestion. One question about this technique: can I
run the directory check loop directly in the contextInitialized event of
the Listener, or is it mandatory to create a new thread?
Dave
Tim Funk wrote:
Various operating system allow hooks to do be notified when items in
the filesystem change. But since we're using java - thats not the case
here so you need to something generic such as the following:
Create a new ServletContextListener - this will run once one webapp
loading. Have this spawn a new thread which watches the directory in
question. The thread will need to perform a directory listing to
detect changes - the strategy for determining changes can vary**. The
thread will operate in an infinite loop sleeping as per your
threshold. The inifinte loop should contain a conditional so it can be
stopped when the destory method of the ServletContextListener is
called too.
David Kerber wrote:
Hi, Tomcatters -
I have a working application to which I need to add a new function,
where I need to watch a networked directory (not on the local tomcat
server machine) for newly-appearing files, which I will then
process. I need to have this done at intervals not exceeding about
two minutes. The files are sent by a remote machine doing an ftp
put, over the internet.
I can handle the file reading and processing with no trouble, but
I've never done this kind of directory watching before. Can somebody
give me some suggestions on how to do this? Is there some kind of
function that will trigger an event when a new file appears? Do I
put a 1 minute sleep in a loop, and check for new files each time
through? Or something else?
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]