[EMAIL PROTECTED] (Oliver Heger) writes: >If we have Loccators, IMO there is no need to keep the base path and >file name stuff in file based configurations. These are things a
+1 ! >concrete Locator has to deal with, and the information needed by a >Locator may vary. So I suggest the following simple method signature: > URL locate(); // eventuelly throws ConfigurationException? +1. With throws, please. We will have to deal with exceptions anyway and it is the job of the application to do so. >Concrete Locators should have getter and setter methods for the >properties they need, e.g. the ClasspathLocator a resource name, the >URLLocator a URL etc. That way a Locator could be created by Digester >and initialized with a SetPropertiesRule, which comes in handy when used >with ConfigurationFactory. Yes. But in this case, I want to have a C'tor which takes the parameters directly. I could live with public class FileLocator implements Locator { public FileLocator() {...} public FileLocator(String dir, String file { setDirectory(dir); setFile(file); } public void setDirectory(String dir) {...} public void setFile(String file) {...} public String getDirectory() {...} public String getFile() {...} public URL locate() {...} } but I want to be able to write a Configuration load still in one line. I don't care whether it is Configuration conf = new PropertiesConfiguration( new FileLocator("/tmp", "foo.properties").locate()); or Configuration conf = new PropertiesConfiguration( new FileLocator().locate("/tmp", "foo.properties")); (though I think that the first one is the better one) but I will not agree to this as the only way: Locator loc = new FileLocator(); loc.setDirectory("/tmp"); loc.setFile("foo.properties"); Configuration conf = new PropertiesConfiguration(loc.locate()); commons-configuration is still a helper to real applications. I want it lean and easy to use. Which means, for normal users, loading a configuration is a straightforward one-liner. If we give the locator implementations some sugar to be used with digester or some other reflection tool, fine, +1. But this still must be an afterthought, not the main thing. Currently, you can write a c-c loading with a single line of code. I want to keep it like this. >Usage of a Locator would then look like: >Locator locator = new MyConcreteLocator(); >// init locator as necessary >Configuration conf = new PropertiesConfiguration(locator); +1. I can also live with Configuration conf = new PropertiesConfiguration(locator.locate()); and let the configuration classes only have C'tors with URL. >in contrast to >Locator locator = new MyConcreteLocator(); >Configuration conf = new PropertiesConfiguration(); >conf.setBasePath(...); >conf.setFileName(...); >conf.load(locator); Yep. That would suck. That is why I'd like to have Configuration conf = new PropertiesConfiguration( new MyConcreteLocator("basepath", "file").locate()); as stated above. My first choice would still be Configuration conf = new PropertiesConfiguration( new MyConcreteLocator("basepath", "file")); and have the configuration classes take a Locator object in its C'tor. But Emmanuel does not like this. Regards Henning -- Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH [EMAIL PROTECTED] +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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]