File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes How build my own Application Setting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How build my own Application Setting" Watch "How build my own Application Setting" New topic

How build my own Application Setting

adi sembiring

Joined: Nov 13, 2009
Posts: 9
Hi ...., I wanna build ApplicationSetting to my application. the application setting can be stored in a file properties or in a database table. the content of applicatino setting is key and value. ex:

I have design my code bellow:
AppSettings Reader

Application Setting Class


so, my questions are:
1. Give your opinion about my code, is there some thing wrong ?
2. I configure my application setting once, while the application start, I configure the application setting with appropriate reader (DbReader or PropertiesReader), I make it singleton. The problem is, While some user edit the database or file directly to database or file, I can't get the changed. now, I wanna implement like ApplicationSettingChangeListener. so if the data change, i will refresh reconfigure my application setting. do you have suggestion ?
Jan Cumps

Joined: Dec 20, 2006
Posts: 2565

I have moved your post to our Java in General forum.

OCUP UML fundamental and ITIL foundation
Karthik Shiraly

Joined: Apr 04, 2009
Posts: 872



The Apache Commons Configuration framework does all that you want: read from different type of data sources, reload on change, and much more.
If you've no compelling reason to roll out your own implementation, you're probably better off using that.
Michael Angstadt
Ranch Hand

Joined: Jun 17, 2009
Posts: 277

Adi, please PostRealCode next time.
The java.util.Properties class can read Java property files, which is what your settings file seems to be. You don't have to manually parse the file yourself.

I agree. Here's the link:
subject: How build my own Application Setting
It's not a secret anymore!