You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Alex Coyle <ac...@f2s.com> on 2005/09/20 22:26:44 UTC
[configuration] Locale aware configuration
Hi there,
Some months ago there was a discussion regarding a decorator for a
configuration, 'ConfigurationLocaleAware', that would provide a locale
sensitive API to get properties. At that time a reference was made to the
'Scarab' project to show how it might be implemented. I'm interested in
creating such a decorator, but I couldn't find much Scarab information to
see how it was tackled there.
Any pointers? I've had a stab at a design, but currently I can't find a way
to avoid using 'instanceof' to find out the type of configuration my
decorator is wrapping, e.g. AbstractFileConfiguration,
DatabaseConfiguration, JNDIConfiguration. This is necessary to create a new
configuration based on the wrapped one, with a 'suffix' for locale sensitive
lookups. This approach doesn't cater for a CompositeConfiguration either -
the only way I can see to do that is provide a locale aware implementation
of a composite configuration.
Thanks
Alex.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [configuration] Locale aware configuration
Posted by Oliver Heger <ol...@t-online.de>.
Alex Coyle wrote:
> Hi there,
>
> Some months ago there was a discussion regarding a decorator for a
> configuration, 'ConfigurationLocaleAware', that would provide a locale
> sensitive API to get properties. At that time a reference was made to
> the 'Scarab' project to show how it might be implemented. I'm
> interested in creating such a decorator, but I couldn't find much
> Scarab information to see how it was tackled there.
>
> Any pointers? I've had a stab at a design, but currently I can't find
> a way to avoid using 'instanceof' to find out the type of
> configuration my decorator is wrapping, e.g.
> AbstractFileConfiguration, DatabaseConfiguration, JNDIConfiguration.
> This is necessary to create a new configuration based on the wrapped
> one, with a 'suffix' for locale sensitive lookups. This approach
> doesn't cater for a CompositeConfiguration either - the only way I can
> see to do that is provide a locale aware implementation of a composite
> configuration.
>
> Thanks
>
> Alex.
>
I was not involved in the discussion you mentioned and don't remeber the
details.
Not sure if I fully understand what you are doing and what you mean by
"'suffix' for locale sensitive lookups. How does your locale sensitive
configuration look like? Does it implement the Configuration interface?
A naive approach would be to have a class LocaleConfiguration that
defines a map for the supported locales. This map would store locales as
keys and corresponding Configuration objects as values. This class would
not implement the Configuration interface because all getter methods
would need an additional argument for the Locale. This could roughly
look as follows (with getProperty() used as example):
public class LocaleConfiguration
{
private Map locales;
Configuration getConfigForLocale(Locale locale)
{
Configuration result = (Configuration) locales.get(locale);
// deal with null values, e.g. use a default locale
return result;
}
public Object getProperty(String key, Locale locale)
{
return getConfigForLocale(locale).getProperty(key);
}
...
}
You seem to do something different, do you?
Oliver
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org