[ 
https://issues.apache.org/jira/browse/SLING-2047?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Robert Munteanu closed SLING-2047.
----------------------------------

> Properly provide locale inheritance support
> -------------------------------------------
>
>                 Key: SLING-2047
>                 URL: https://issues.apache.org/jira/browse/SLING-2047
>             Project: Sling
>          Issue Type: Improvement
>          Components: Extensions
>    Affects Versions: I18n 2.0.4
>            Reporter: Felix Meschberger
>            Assignee: Felix Meschberger
>             Fix For: I18n 2.1.0
>
>
> The ResourceBundle class is intended to be used with inheritance of resources 
> from parent resource bundles. Thus the ResourceBundle.getObject(String) is 
> implemented along these lines:
>     Object obj = handleGetObject(key);
>     if (obj == null) {
>        if (parent != null) {
>           obj =  parent.getObject(key);
>        }
>        if (obj == null) {
>          throw new MissingResourceException(...)
>        }
>     }
>     return obj;
> The JcrResourceBundle.handleObject(String key) method is implemented like 
> this:
>         Object value = // get from the repository resources
>         return (value == null) ? key : value;
> That is the key is returned if there is no value. This, though, breaks the 
> inheritance chain intended by the ResourceBundle.getObject(String) method. We 
> should fix this along these lines:
>  * The JcrResourceBundleProvider provides a root ResourceBundle 
> implementation as follows:
>        - handleObject(String key) always  returns the key
>        - getLocale() returns an empty Locale
>        - getKeys() always returns an empty enumeration
>  * The root ResourceBundle is used as the parent for all JcrResourceBundle 
> instances which have no Locale induced parent
>  * JcrResourceBundle.handleGetObject(String key) only returns the value for 
> the given locale
> This way we can keep the guarantee that getObject(String key) method of a 
> ResourceBundle provided by the JcrResourceBundleProvider never throws a 
> MissingResourceException.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to