开发者

Auto-reload changed files in Java

开发者 https://www.devze.com 2023-04-13 08:08 出处:网络
I have a lot of configuration files that modify how my application behaves.I want to be able to make a change and it gets reflected in the application right away when saving the file.Is there a Java l

I have a lot of configuration files that modify how my application behaves. I want to be able to make a change and it gets reflected in the application right away when saving the file. Is there a Java library to help with this?

I could simply keep a list of files with their timestamps and continuously check in a background thread when a timestamp changes. Doesn't seem too difficult, but maybe there's a more efficient way to do this? Custom triggers when certain properties have changed would be nice.

I'm using Spring 3.1, is there a built-in mechanism or solution which works nicely with Spring?

UPDATE: Apparentl开发者_如何转开发y JDK7 now includes this functionality through its Watch Service API: "Most file system implementations have native support for file change notification. The Watch Service API takes advantage of this support where available. However, when a file system does not support this mechanism, the Watch Service will poll the file system, waiting for events." So this'll be my motivation to migrate to JDK7.


Edited:

http://commons.apache.org/configuration/userguide/howto_filebased.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号