Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 93503 invoked from network); 13 Feb 2011 17:51:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 13 Feb 2011 17:51:36 -0000 Received: (qmail 21224 invoked by uid 500); 13 Feb 2011 17:51:35 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 20667 invoked by uid 500); 13 Feb 2011 17:51:33 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 20659 invoked by uid 99); 13 Feb 2011 17:51:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 Feb 2011 17:51:32 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [212.227.126.187] (HELO moutng.kundenserver.de) (212.227.126.187) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 Feb 2011 17:51:27 +0000 Received: from [192.168.178.20] (trir-5d800424.pool.mediaWays.net [93.128.4.36]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0Ld3uy-1QWqca2LQG-00iQGP; Sun, 13 Feb 2011 18:51:04 +0100 Message-ID: <4D581A06.3090705@oliver-heger.de> Date: Sun, 13 Feb 2011 18:51:02 +0100 From: Oliver Heger User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6 MIME-Version: 1.0 To: Commons Users List Subject: Re: [configuration] How to edit a bean using apache.commons.configuration .... References: <4D56A923.8010108@oliver-heger.de> <8A269BCE-6786-4F2C-A123-1DD8778017A3@dslextreme.com> In-Reply-To: <8A269BCE-6786-4F2C-A123-1DD8778017A3@dslextreme.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:SSs/SLZnax7j9i+c0Yg0H2264UB7q1BG4WVgrogHX4u eaoxi/Am3qeGL7OTVJcc+xeMmY0AWVeZucMJ+yg/5Knm4DfE+y ayVZyH2iAr1+UEKX1W1gb/UrWYzRTnD0tTsX1VLbPvaa9hoNPH pEhVkn5D1dt5ABMbjlS4nqkRYYZk4/dWQemXRUM9NBji7qpT7v C3pE8P4wyZghkIv320dAw== Am 13.02.2011 17:13, schrieb Ralph Goers: > 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 I fully agree with Ralph. There are specialized solutions for bean persistence which are more appropriate for your use case. If you are on Java 1.6, you have built in support for JAXB [1] which might be an option, too. Oliver [1] http://download.oracle.com/javase/6/docs/technotes/guides/xml/jaxb/index.html > > 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 >> 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: >>> >>> >>> >>> >> closable="false" resizable="true" defaultWidth="400" >>> defaultHeight="250"> >>> >> backColor="#ffffff" foreColor="0080ff" iconName="myicon" /> >>> >>> >>> >>> >>> 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 > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org