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/03 01:34:12 UTC

[jira] [Resolved] (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:all-tabpanel ]

Ian Boston resolved SLING-2625.
-------------------------------

    Resolution: Fixed
      Assignee: Ian Boston

Patch applied, and package version incremented appropriately. Thanks.
                
> 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
>    Affects Versions: Commons OSGi 2.1.0
>            Reporter: Chetan Mehrotra
>            Assignee: Ian Boston
>            Priority: Minor
>             Fix For: Commons OSGi 2.1.2
>
>         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