Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 5214 invoked from network); 8 Dec 2004 10:01:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 8 Dec 2004 10:01:58 -0000 Received: (qmail 76909 invoked by uid 500); 8 Dec 2004 10:01:51 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 76889 invoked by uid 500); 8 Dec 2004 10:01:50 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 76873 invoked by uid 99); 8 Dec 2004 10:01:50 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from mail.hometree.net (HELO mail.hometree.net) (194.77.152.181) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 08 Dec 2004 02:01:49 -0800 Received: from tangens.hometree.net (mail.hometree.net [194.77.152.181]) by mail.hometree.net (8.12.11/8.12.11) with ESMTP id iB8A1dZH002668 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 8 Dec 2004 11:01:39 +0100 Received: (from news@localhost) by tangens.hometree.net (8.12.11/8.12.11/Submit) id iB8A1d0h002666 for commons-dev@jakarta.apache.org; Wed, 8 Dec 2004 11:01:39 +0100 To: commons-dev@jakarta.apache.org Path: not-for-mail From: "Henning P. Schmiedehausen" Newsgroups: hometree.jakarta.commons.dev Subject: Re: [configuration] File locator Date: Wed, 8 Dec 2004 10:01:39 +0000 (UTC) Organization: INTERMETA - Gesellschaft fuer Mehrwertdienste mbH Lines: 86 Message-ID: References: <41B5E5E4.5080602@lfjr.net> Reply-To: hps@intermeta.de NNTP-Posting-Host: forge.intermeta.de X-Trace: tangens.hometree.net 1102500099 2041 194.77.152.164 (8 Dec 2004 10:01:39 GMT) X-Complaints-To: news@intermeta.de NNTP-Posting-Date: Wed, 8 Dec 2004 10:01:39 +0000 (UTC) X-Copyright: (C) 1996-2005 Henning Schmiedehausen User-Agent: nn/6.6.5 X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Emmanuel Bourg writes: >Here is a quick attempt at implementing the Locator strategy discussed >earlier. Feel free to comment :) [...] > /** > * Creates and loads the configuration from the specified file. > * >+ * @param fileName The name of the file to load. >+ * >+ * @throws ConfigurationException Error while loading the file >+ * @since 1.1 >+ */ >+ public AbstractFileConfiguration(String fileName, Locator locator) throws ConfigurationException >+ { >+ this(locator.locate(null, fileName)); >+ } I don't like this. Yet another C'tor. We shouldn't add C'tors, we should deprecate AbstractFileConfiguration(String) and force people to use the locators directly. What is wrong with Configuration conf = new PropertiesConfiguration(new ClassPathLocator().locate(null, "torque.properties")); and ClassPathLocator implemented as public class ClassPathLocator implements Locator { public URL locate(...) {...} } I hate adding "convenience constructors". They always come back to haunt you. >+ >+ /** >+ * Creates and loads the configuration from the specified file. >+ * > * @param file The file to load. > * @throws ConfigurationException Error while loading the file > * @since 1.1 >@@ -149,9 +164,21 @@ > */ > public void load(String fileName) throws ConfigurationException > { >+ load(fileName, LocatorUtils.getDefaultLocator()); >+ } Same here. Deprecate all load(...) except load(URL ...) and let the locator implementations do the translation from file to URL. >+ >+ /** >+ * Locate the specified file and load the configuration. >+ * >+ * @param fileName the name of the file loaded >+ * >+ * @throws ConfigurationException >+ */ >+ public void load(String fileName, Locator locator) throws ConfigurationException >+ { > try > { >- URL url = ConfigurationUtils.locate(basePath, fileName); >+ URL url = locator.locate(basePath, fileName); > load(url); > } > catch (ConfigurationException e) Same here. The idea of the locators is to _reduce_ code. Not add new methods. Regards Henning -- Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH hps@intermeta.de +49 9131 50 654 0 http://www.intermeta.de/ RedHat Certified Engineer -- Jakarta Turbine Development -- hero for hire Linux, Java, perl, Solaris -- Consulting, Training, Development What is more important to you... [ ] Product Security or [ ] Quality of Sales and Marketing Support -- actual question from a Microsoft customer survey --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org