commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: [configuration] How to edit a bean using apache.commons.configuration ....
Date Sun, 13 Feb 2011 16:13:26 GMT
Commons Configuration isn't meant to be a bean entity framework but a way for applications
to access configuration data. Therefore it doesn't follow normal Java bean semantics.  Although
you could probably make it function as one I'd be surprised if it would be nearly as efficient
as some of the true Java Bean frameworks.  http://java-source.net/open-source/xml-parsers
has a decent list of various tools you could use to do this.

Ralph

On Feb 12, 2011, at 9:35 PM, Moein Enayati wrote:

> Dear Oliver
> 
> Thanks a lot for your nicely reply.
> but you know , I was thinking of a service approach in which I have an
> entity(bean) which stored in XML file and by request , I load it into a
> bean-object and give it to the client (another module) and after all changes
> applied of the bean-object , I save it in it's corresponding location in xml
> file.
> 
> is there any way to do so , or is it a correct approach of using
> configuration entities?
> 
> thanks again / Moein
> 
> 
> 
> On Sat, Feb 12, 2011 at 7:07 PM, Oliver Heger
> <oliver.heger@oliver-heger.de>wrote:
> 
>> Hi,
>> 
>> Am 12.02.2011 15:58, schrieb Moein Enayati:
>> 
>> Dear all
>>> 
>>> I'm newly familiar with apache.commons and wondering of having an
>>> XML-Preferences file for my java applicaiton . till know I found
>>> apache.commons.configuration so useful in set/getproperties and also in
>>> getting a saved bean from xml resource.
>>> but I need to load a bean and apply user changes on it and save it again
>>> in
>>> its previous location in xml file.
>>> 
>>> would you please help me is there any way to do so ?
>>> 
>>> thanks/Moein
>>> 
>>> 
>> with "bean" you mean the bean declarations as described in the user's guide
>> [1] I assume.
>> 
>> Well, basically a bean declaration is no different from normal properties
>> defined in the XML document. This means you can use setProperty() with the
>> corresponding keys to alter parts of the declaration.
>> 
>> Take the following example from the user's guide:
>> 
>> <config>
>> <gui>
>>   <windowManager config-class="examples.windows.DefaultWindowManager"
>>     closable="false" resizable="true" defaultWidth="400"
>>     defaultHeight="250">
>>     <styleDefinition config-class="examples.windows.WindowStyleDefinition"
>>       backColor="#ffffff" foreColor="0080ff" iconName="myicon" />
>>   </windowManager>
>> </gui>
>> </config>
>> 
>> If you want to change the backColor property of the style definition of the
>> window manager bean, you could use the following call:
>> 
>> config.setProperty("gui.windowManager.styleDefinition[@backColor]",
>>   "#0000ff");
>> 
>> Oliver
>> 
>> [1]
>> http://commons.apache.org/configuration/userguide/howto_beans.html#Declaring_and_Creating_Beans
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>> 
>> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message