Return-Path: X-Original-To: apmail-commons-user-archive@www.apache.org Delivered-To: apmail-commons-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C0ED610670 for ; Mon, 2 Mar 2015 20:45:34 +0000 (UTC) Received: (qmail 91687 invoked by uid 500); 2 Mar 2015 20:45:33 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 91558 invoked by uid 500); 2 Mar 2015 20:45: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 91537 invoked by uid 99); 2 Mar 2015 20:45:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Mar 2015 20:45:33 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE X-Spam-Check-By: apache.org Received-SPF: error (nike.apache.org: local policy) Received: from [212.227.126.187] (HELO mout.kundenserver.de) (212.227.126.187) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Mar 2015 20:45:06 +0000 Received: from [192.168.178.22] ([188.97.46.223]) by mrelayeu.kundenserver.de (mreue003) with ESMTPSA (Nemesis) id 0LaYbD-1XmLop0STv-00mH4C for ; Mon, 02 Mar 2015 21:44:44 +0100 Message-ID: <54F4CBCF.5030406@oliver-heger.de> Date: Mon, 02 Mar 2015 21:45:03 +0100 From: Oliver Heger User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Commons Users List Subject: Re: [configuration] References: <06EBADA8F5D5294B880B31A29FFEB6C126F7EE@PHXFISWMSGMB13.FNFIS.com> In-Reply-To: <06EBADA8F5D5294B880B31A29FFEB6C126F7EE@PHXFISWMSGMB13.FNFIS.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:XLzKJjHVE93wn1Nq4D8rkJsu2bKGB7irqcCfnu8XhfPCB3kRJWW xLhcSl/PDTEb6krMVaxNyjk3pvhhU20lZcn1kB4DEaJ/aM+EtCBdaPWVBHqNgjtaltsdbwP TwgOPyLGJ399OPlg31+VctRYMJXGRw655qGewA7R5YZ0gnsr3odnJE37x/mCQ8Ux1yBvHri IvHSjDR3EYDyZt7OCRUXg== X-UI-Out-Filterresults: notjunk:1; X-Virus-Checked: Checked by ClamAV on apache.org Am 02.03.2015 um 10:53 schrieb Velladurai Pandian, Ashok Kumar: > I have a hierarchy of property files which are available in various folders in my file system. The file names are same but the folders are named based on the base group and specific group id and. > > I have a requirement of creating group based configurations of all the available property files. Based on the user login I need load their respective group and if not available at that level it would go to the base group and get the key. > > I am trying use the MultiFileConfigurationBuilder and trying to set the pattern to combine the configurations. To the pattern I would set the group id and get the configuration and merge with that of the base group. > > But the pattern does not seem to be working. Is it possible to load and merge the configurations just only using the config.xml files? > > Please let me know if you have a better approach. > > Parameters params = new Parameters(); > MultiFileBuilderParameters multiParam = params.multiFile().setFilePattern("${GROUP_ID}/ app_settings.properties").setManagedBuilderParameters(params.fileBased().setBasePath("C:/a_container/MyApp/")); > MultiFileConfigurationBuilder builder = new MultiFileConfigurationBuilder( > PropertiesConfiguration.class).configure(multiParam); > Map params1 = new HashedMap(); > params1.put("GROUP_ID", "987987"); > builder.setParameters(params1); > Configuration conf = builder.getConfiguration(); > sopAllKeys((FileBasedConfiguration) conf); The problem is that the variable in the file pattern cannot access parameters passed to the builder. It is interpreted by the typical interpolation mechanisms used by configuration objects (refer to http://commons.apache.org/proper/commons-configuration/userguide/howto_basicfeatures.html#Variable_Interpolation). Maybe you can solve your problem with Java system properties. Set the name of the directory as a specific system property and reference the same property in your expression with the "sys" prefix (e.g. ${sys:mySystemProperty}). There is an example which embeds a multi file configuration into a DynamicCombinedConfiguration also using system variables to load the correct configuration files: http://commons.apache.org/proper/commons-configuration/userguide/howto_multitenant.html#Sample_Configuration HTH Oliver > > Regards, > Ashok > > _____________ > The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you. > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org