commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henning P. Schmiedehausen" <...@intermeta.de>
Subject Re: [configuration] Loading and Saving
Date Thu, 09 Sep 2004 10:11:13 GMT
Emmanuel Bourg <smanux@lfjr.net> writes:

Using a Decorator around Configuration might be the coolest solution
to the return null vs. throw Exception problem. We might add a
decorator that throws an Exception on a null return value.

So if you need this you use e.g.

Configuration conf = ExceptionDecorator.decorate(Turbine.getConfiguration());

with

public class ExceptionDecorator
	implements Configuration
{
	public static Configuration decorate(Configuration conf)
	{
		return new ExceptionDecorator(conf);
	}

	private Configuration conf = null;

	private ExceptionDecorator(Configuration conf)
	{
		this.conf = conf;
	}

	public getString(String propertyName)
	{
		String foo = conf.getString(propertyName);
		if (foo == null)
		{
			throw Exception...
		}

		return foo;
	}

[...]
}

and be done with this.  There might be even more elegant ways to write
such a decorator. ;-)

	Regards
		Henning

>Henning P. Schmiedehausen wrote:

>> Don't be too humble. Apache Gump tells us that commons-configuration
>> has seven direct and 71 (!) indirect dependees on commons-configuration:
>> 
>> http://brutus.apache.org/gump/public/gump_stats/project_dependees.html

>Nice, I didn't know [configuration] was already included in Gump :) Is 
>there a way to track back the projects using it ?


>> For the matter of the switch: Emmanuel: How do you plan to implement
>> this?  Additional C'tors taking a boolean? Or a boolean setter?

>I intended to add a boolean setter, but I was still pondering where, 
>whether in the Configuration interface or just in AbstractConfiguration ?


>> Personally, I'd still prefer the "two methods for everyone" approach
>> that Hibernate does. getBoolean(String property) returns null if
>> property does not exist and fetchBoolean(String propety) throws an
>> Exception.

>Why not but I'm not sure Eric will like this ;) There was a discussion 
>recently on the addition of getters to the Configuration interface 
>(http://nagoya.apache.org/bugzilla/show_bug.cgi?id=29617) and we debated 
>about the length of the API.

>Emmanuel Bourg


>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-dev-help@jakarta.apache.org

-- 
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

"Fighting for one's political stand is an honorable action, but re-
 fusing to acknowledge that there might be weaknesses in one's
 position - in order to identify them so that they can be remedied -
 is a large enough problem with the Open Source movement that it
 deserves to be on this list of the top five problems."
                       -- Michelle Levesque, "Fundamental Issues with
                                    Open Source Software Development"

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message