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 36979792D for ; Tue, 29 Nov 2011 12:30:55 +0000 (UTC) Received: (qmail 23272 invoked by uid 500); 29 Nov 2011 12:30:53 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 23180 invoked by uid 500); 29 Nov 2011 12:30:53 -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 23172 invoked by uid 99); 29 Nov 2011 12:30:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Nov 2011 12:30:53 +0000 X-ASF-Spam-Status: No, hits=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of gcjcu-commons-user@m.gmane.org designates 80.91.229.12 as permitted sender) Received: from [80.91.229.12] (HELO lo.gmane.org) (80.91.229.12) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Nov 2011 12:30:45 +0000 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RVMpK-0004Ow-6L for user@commons.apache.org; Tue, 29 Nov 2011 13:30:22 +0100 Received: from mail.scalaris.com ([62.154.225.82]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 29 Nov 2011 13:30:22 +0100 Received: from joerg.schaible by mail.scalaris.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 29 Nov 2011 13:30:22 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: user@commons.apache.org From: =?UTF-8?B?SsO2cmc=?= Schaible Subject: Re: Commons Configuration - Variable interpolation not working Followup-To: gmane.comp.jakarta.commons.user Date: Tue, 29 Nov 2011 13:30:07 +0100 Lines: 47 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: mail.scalaris.com User-Agent: KNode/4.4.11 Hi, Vinicius Carvalho wrote: > Hi there! I'm trying to get Variable interpolation to work. But it seems > that either I missed something at the docs or there's a bug here. > > All I need is to replace a ${app} on my properties file to contain a > string instead > > so whenever I have ${app}.maxUsers=10 I want AppName.maxUsers=10 > > Here's some code: > > private class AppInterpolator extends StrLookup{ > @Override > public String lookup(String var) { > return "#{"+appName+"}"; > } > } > > ConfigurationInterpolator.registerGlobalLookup("app", new > AppInterpolator()); > config = new CompositeConfiguration(); > PropertiesConfiguration localProps = new > PropertiesConfiguration(this.getClass().getClassLoader().getResource(PROPERTIES_FILE_NAME)); > this.config.addConfiguration(localProps); > > > But after using config.getProperty("") I've noticed that the property here > is ${app}.maxUsers and not AppName.maxUsers > > I've also noticed that it seems that PropertiesFile does not reference > ConfigurationInterpolator at all. > > Any ideas on how to fix this? Let me cite the Javadoc or AbstractConfiguration: "Support for variable interpolation. Property values containing special variable tokens (like ${var}) will be replaced by their corresponding values." *values*, not *keys* - Jörg --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org