Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 95257 invoked from network); 26 Nov 2008 21:38:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Nov 2008 21:38:07 -0000 Received: (qmail 98459 invoked by uid 500); 26 Nov 2008 21:38:16 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 97400 invoked by uid 500); 26 Nov 2008 21:38:14 -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 97389 invoked by uid 99); 26 Nov 2008 21:38:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Nov 2008 13:38:14 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of bboyle18@gmail.com designates 209.85.198.242 as permitted sender) Received: from [209.85.198.242] (HELO rv-out-0708.google.com) (209.85.198.242) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Nov 2008 21:36:48 +0000 Received: by rv-out-0708.google.com with SMTP id k29so742182rvb.30 for ; Wed, 26 Nov 2008 13:37:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=tLTFch3bNJtFF+noxYM0T6INltxMDD7YmGNguH6KRs8=; b=ndticAvszFdPEAsUiFWWI2k+PVEGh+fULFtOQSV89mWOlHojvqB9QScg7FpT2MW13R CL/TQi+ql8W4PhamBtOlp6mdbCtoD4U+4/eLu9x5AM85X7m7dQMBDPEfXFeNORU1s4p/ LSpXayRo4DsN8+l0QDXGfYJuw44nmvejz6hro= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=Kk7aCrfFX8/bE7Lw6H8oI/fJbpMXWrn1Sg9CfeArtFaRJO7oefnv7nzH/y2BPMx6N0 CVrre2mG61B9YfvRyIBvT9J/Jihm16EYiBmKrIXCjAD7ZjXKe9pQZFb+ZVip42dd22Td KwRhkHmevPSX5vYR3XBFlKc4+UNnfQ5T6hP1A= Received: by 10.141.45.16 with SMTP id x16mr3080092rvj.289.1227735454280; Wed, 26 Nov 2008 13:37:34 -0800 (PST) Received: by 10.141.186.10 with HTTP; Wed, 26 Nov 2008 13:37:34 -0800 (PST) Message-ID: <8f5507fb0811261337n5cc6c074pf11ee5efb123fd21@mail.gmail.com> Date: Wed, 26 Nov 2008 21:37:34 +0000 From: "Brian Boyle" To: "Commons Users List" Subject: Re: Commons Configuration - Saving a combined configuration In-Reply-To: <492DC04F.6030008@oliver-heger.de> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_21893_24795313.1227735454271" References: <8f5507fb0811261244i6ac20c9anee72c02decc164ce@mail.gmail.com> <492DB9EE.6030306@oliver-heger.de> <8f5507fb0811261328v11a3770v21c5fb763a8d87d1@mail.gmail.com> <492DC04F.6030008@oliver-heger.de> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_21893_24795313.1227735454271 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Thanks Oliver, that worked. Thanks for your help with this. Brian On Wed, Nov 26, 2008 at 9:31 PM, Oliver Heger wrote: > Brian Boyle schrieb: > >> Hi Oliver, >> >> Thanks for replying so quickly. >> I tried out your suggestion and it works perfectly. >> I've had a look at the CombinedConfiguration object and I managed to get >> it >> working. I have added my code below.....is this the correct way to do this >> or is there an even easier way to do it with CombinedConfiguration? >> >> Cheers, >> >> Brian >> >> CombinedConfiguration cc = new CombinedConfiguration(new >> OverrideCombiner()); >> cc.addConfiguration(masterConf); >> cc.addConfiguration(localConf); >> >> XMLConfiguration result = new XMLConfiguration(); >> result.setRootNode(cc.getRootNode()); >> XMLConfiguration finalResult = new XMLConfiguration(result); >> finalResult.setRootElementName("IMConfig"); >> finalResult.save("resources/CombinedConfig.xml"); >> >> > I think you should be able to do > > CombinedConfiguration cc = new CombinedConfiguration(new > OverrideCombiner()); > cc.addConfiguration(masterConf); > cc.addConfiguration(localConf); > XMLConfiguration result = new XMLConfiguration(cc); > result.save(...); > > Oliver > > > >> On Wed, Nov 26, 2008 at 9:04 PM, Oliver Heger >> wrote: >> >> Brian Boyle schrieb: >>> >>> Hi there, >>> >>>> I am using the OverrideCombiner class to combine two XMLConfigurations >>>> together. This works fine and then I set this combined configuration as >>>> the >>>> RootNode of a new XMLConfigruation. I am then trying to save this newly >>>> created configuration as a new file and this does not seem to work. Does >>>> anybody know if this is possible or have a missed a step along the way? >>>> >>>> Thanks, >>>> >>>> Brian >>>> P.S. Here is my code. >>>> >>>> XMLConfiguration masterConf = new XMLConfiguration(); >>>> XMLConfiguration localConf = new XMLConfiguration(); >>>> masterConf.load("resources/Masterconfig.xml"); >>>> localConf.load("resources/localConfig.xml"); >>>> >>>> NodeCombiner combiner = new OverrideCombiner(); >>>> ConfigurationNode cn = >>>> combiner.combine(localConf.getRootNode(), >>>> masterConf.getRootNode()); >>>> >>>> XMLConfiguration result = new XMLConfiguration(); >>>> result.setRootNode(cn); >>>> result.save("resources/CombinedConfig.xml"); >>>> >>>> >>>> The problem is that the configuration nodes contain references to the >>> XML >>> DOM elements they correspond to. These references are also used by >>> XMLConfiguration to find out, which nodes have been changed and must be >>> written. >>> >>> To solve your problem these references must be cleared. The easiest way >>> to >>> do this is using the constructor of XMLConfiguration that takes another >>> hierarchical configuration as argument. You can try creating another >>> XMLConfiguration as copy of the existing one: >>> >>> XMLConfiguration result = new XMLConfiguration(); >>> result.setRootNode(cn); >>> XMLConfiguratiion finalResult = new XMLConfiguration(result); >>> finalResult.save(...); >>> >>> BTW, is there a reason why you do not use CombinedConfiguration? This >>> class >>> will do the work with the combiners for you. You can then create the >>> result >>> XMLConfiguration from this combined configuration. >>> >>> HTH >>> Oliver >>> >>> --------------------------------------------------------------------- >>> 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 > > -- Brian Boyle Mobile: 087 418 5215 Email: bboyle18@gmail.com ------=_Part_21893_24795313.1227735454271--