I want to develop a program to watch a configured folder. If files are copied into the folder, I need to trigger a set of processes with the copied files.
My current thought is to write a Thread that checks the folder for new files placed. The Thread will sleep for configured time between each poll. I do not want to do this approach since I have to keep list of old files processed to know which are the new files that should be processed. And I feel there will not be instant processing of placed files due to intermittent sleep applied on the Thread.
I need a thing like JMS / EJB (Message Driven bean) in simple core Java. I might be wrong here. Let me know if you have any suggestions.
In most operating systems the "Last Active Date" of a folder is changed whenever a new file is created in that folder. This means you don't need to keep track of what files are in the folder at any time. Just keep track of the folder's last active date.
There are also people who have written implementations of this process which work with pre-Java-7 versions, using JNI to access folder-monitoring services from the O/S. You could track them down on the web, I don't remember any names.