Search code examples
javaspringtomcatlistener

Spring Directory Listener


I'm creating a web application that uses Apache Tomcat (Latest), Spring 3, Struts2 and Hibernate. I need to have a listener that observes a directory for any new XML files that appear. While the web application is deployed onto Tomcat and running it should keep doing this.

  1. What method is recommended when doing something like this, using these frameworks?
  2. Are there any examples that I can look at to assist with the beginning stages?

Solution

  • Try jdk7 WatchService. I have already done it a project which has a similar structure to the one you have. Otherwise you could try to use FileAlterationListner from org.apache.commons.io. I would rather go for jdk7 as it worked perfectly.