shawn
shawn

Reputation: 4223

How can I implement something like apache reload in java?

I have written a server application but I want to be able to edit the server's configuration while it is running and reload it into the server's memory without restarting, is there any way to do this in java other than creating a listening socket for configuration purposes?

Upvotes: 1

Views: 92

Answers (1)

Grooveek
Grooveek

Reputation: 10094

In the library Apache Commons IO, you get for free a File monitor which you can use to know if a configuration file has been modified and handle the modification

In Java 7, you have a similar functionality in NIO2, a WatchService I think.

After that, correctly handling the modification depends on your architecture. You may have a look at ClassLoader to discard certain part of your configuration and load others

Upvotes: 2

Related Questions