Extension-Configuration centralised in config.xml
Posted: 03 Feb 2009, 20:32
I would like to make a certain file-path in my extension configurable (for example configuring a target-path for a custom logfile).
It could work something like this example-snippet. I added a child-element to "extension" where i could add variables for those extensions. These could then ideally be retrieved via some helper-method.
Positive:
- All your configuration goes into one file
- You don't have to mess with File-Parsing in the extension
- You don't have to recompile to alter some simple thing in the extension
Additional Implementation idea:
The Helper-method could be called like getVarOrDefaultTo("logfile_path","/var/log/sfs/"); Meaning, get a var called logfile_path from the config.xml, but if it isn't present, default to the given value there.
Well - that's the idea. The implementation doesn't need to be close to my description, but the basic thing (config in config.xml) would be pretty neat.
Thanks!
It could work something like this example-snippet. I added a child-element to "extension" where i could add variables for those extensions. These could then ideally be retrieved via some helper-method.
Code: Select all
<Zone name="demo" uCountUpdate="true" maxUsers="4000" customLogin="true">
<Extensions>
<extension
name="Logger"
className="de.amenthes.sfs.extension.Logger"
type="java">
<var name="logfile_path" type="string">/var/log/sfs/chatlog.txt</var>
</extension>
</Extensions>
</Zone>- All your configuration goes into one file
- You don't have to mess with File-Parsing in the extension
- You don't have to recompile to alter some simple thing in the extension
Additional Implementation idea:
The Helper-method could be called like getVarOrDefaultTo("logfile_path","/var/log/sfs/"); Meaning, get a var called logfile_path from the config.xml, but if it isn't present, default to the given value there.
Well - that's the idea. The implementation doesn't need to be close to my description, but the basic thing (config in config.xml) would be pretty neat.
Thanks!