Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to watch file directory tree w/o poling

 
Siegfried Heintze
Ranch Hand
Posts: 408
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does the JBoss server detect when I drop a new WAR or EAR file into the drop directory? I noticed that JBoss (and I think other EJB containers) automagically expands a EAR/WAR file when it appears. Does it poll for new files?

I hope not. Windows has a function that allows C++ programmers to specify a call back function whenever there is a modification in the specified directory. I imagine linux/freebsd has this function too? I hope so.

Anyway, how can I write a java program that does not poll the file modification times to detect a new or modified file or directory? Can I do it with out JNI/C? I hope so.
Thanks,
Siegfried
 
Stephan van Hulst
Bartender
Posts: 6320
78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not without writing native code.

I believe Java 7 will provide this feature, but you'll have to wait for it.
 
Maneesh Godbole
Saloon Keeper
Posts: 11178
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
Rob Spoor
Sheriff
Pie
Posts: 20665
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:I believe Java 7 will provide this feature, but you'll have to wait for it.

It will, with java.nio.file.WatchService, but that too may use polling internally if the file system doesn't support notifications.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic