• Post Reply Bookmark Topic Watch Topic
  • New Topic

Timer app. and config file  RSS feed

 
wgb
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need to write an application that uses a timer to check for a new file in a specific directory on a named server on a timed basis (probably every 24 hours). I also need a configuration file that can be used to define the frequency of the action (in minutes or hours), the server name and/or address and other things. I've written something similar in the past that ran under Tomcat and used a ServletContext to manipulate the values in the configuration file but all of that will not be necessary in this case. I need information on which classes to use to read the config. file as well as an example of a file or just general advice on where to get information of this type. The Timer class is straightforward. The config. file and reading it and storing it's values is unclear.

Any advice would be greatly appreciated!

Thanks,
Bill
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the Properties class which can read and write properties properties with streams to files or anywhere else that streams can go. It might be more buzzword compliant to use XML. If you're not experienced with XML it could be a good learning experience, or maybe just way too time consuming.

I like to build a class that reads configuration and sets the configuration on the real worker classes that need it. That way the code that launches the timer has no dependencies on the configuration file or whether it is plain text, XML, or whatever. That makes it easier to unit test or reuse. Loading config is one aspect of what is sometimes called an Application Assembler.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!