File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How build my own Application Setting" Watch "How build my own Application Setting" New topic
Author

How build my own Application Setting

adi sembiring
Greenhorn

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



Test



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
Bartender

Joined: Dec 20, 2006
Posts: 2476
    
    7

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


OCUP UML fundamental and ITIL foundation
youtube channel
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 475
    
    3
@Adi:

Hi,

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: 272

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.



SCJP 6 || SCWCD 5
 
Consider Paul's rocket mass heater.
 
subject: How build my own Application Setting
 
Similar Threads
is it worth adding a class to distinguish types
Working with files in EJB
Error at form_TextFiled
Object persistance causing OutOfMemoryError
Handler Class - Is it correct?