**DONOTDELETE**
(Unregistered)
03/06/06 02:56 PM
Re: A much smarter way to load properties and onfi

Here's what sucks about JFig
1. too complicated
2. xml config files suck
3. the good things about the framework such as "include" don't work in .ini files, only with xml (see item #2)
here's a better way to go:

creating a heirarchical resource (like resource bundle) is a good way to go. For example let's say you have a set of folders like this
- foo/ (folder)
- bar/ (folder)
- baz/ (folder)
Then inside those folders you have one or more properties files. Your configuration app would then assume the properties are prefixed with the directory (or choose your approach here), so when you ask for the property via ConfigManager (or choose your own class name here) via some method like:
ConfigManager cm = getConfigManager ...
cm.getProperty("foo.property..."); // returns property in foo
or
cm.getPropety("baz.property..."); // returns a property in baz

I implemented something like this for a Swing (yuk) app I worked on that has a folder named "global" for the global application properties and then i implement a <code>public String getName();</code> method for every component that needed config settings so it could grab properties in a folder with the same name as the component, otherwise it would get the global properties with that key. It works out pretty well because you can override configuration settings for particular components, otherwise use the global properties for things like labels, input field defaults and so on.

If you are interested in this code just email me josgraha [at] gmail [dot] com.

BR_Joe_Graham



Contact us JavaWorld

Powered by UBB.threads™ 6.5.5

Featured White Papers


RESEARCH CENTERS: Java Standard Edition | Java Enterprise Edition | Java Micro Edition | Development Tools
About Us | Advertise | Contact Us | Terms of Service/Privacy
Copyright, 2006-2008 Network World, Inc. All rights reserved.