You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Ian Boston (JIRA)" <ji...@apache.org> on 2012/11/01 02:11:13 UTC

[jira] [Commented] (SLING-2625) Utility method to convert configuration value to map

    [ https://issues.apache.org/jira/browse/SLING-2625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13488404#comment-13488404 ] 

Ian Boston commented on SLING-2625:
-----------------------------------

The patch LGTM, applies, builds etc with no problems.
It will need to have the package versioned to 2.2.0 (currently 2.1.0) as it adds a new method to PropertiesUtil see[1]. That needs wider discussion.


1 http://sling.apache.org/site/version-policy.html
                
> Utility method to convert configuration value to map
> ----------------------------------------------------
>
>                 Key: SLING-2625
>                 URL: https://issues.apache.org/jira/browse/SLING-2625
>             Project: Sling
>          Issue Type: Improvement
>          Components: Commons
>            Reporter: Chetan Mehrotra
>            Priority: Minor
>         Attachments: SLING-2625.patch
>
>
> As per current form support for capturing configuration values its not possible to capture key=value pairs. To enable capturing of such pairs through configuration admin ui one has to use an array property consisting of key=value pairs
> @Property(value = {
>    "poolSize=5",
>    "timeout=50",
> })
> private static final String DATASOURCE_PROPS = "options";
> It would be helpful to have a method in org.apache.sling.commons.osgi.PropertiesUtil.toMap(Object value,String[] defaultValue). Which can parse such config and converts it to a map. Attached patch provides such an implementation which does the conversion using following rules
> 1. Entries are of the form key=value
> 2. Key is trimmed
> 3. Value is trimmed. If a trimmed value results in an empty string it is treated as null
> 4. Malformed entries like 'foo','foo=' are ignored
> 5. Map entries maintain the input order i.k linkedhashmap

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira