Romain Manni-Bucau created DELTASPIKE-1220:
----------------------------------------------

             Summary: add converter option to @ConfigProperty
                 Key: DELTASPIKE-1220
                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-1220
             Project: DeltaSpike
          Issue Type: New Feature
            Reporter: Romain Manni-Bucau


This will configure a nomals-scoped bean class used to lookup a CDI bean used 
as converter for the configuration:

{code}
    @Inject
    @ConfigProperty(name = "urlListFromProperties", converter = UrlList.class)
    private List<URL> urlListFromProperties;
{code}

assuming we have:

{code}
    public class UrlList implements ConfigResolver.Converter<List<URL>>
    {
        @Override
        public List<URL> convert(final String value)
        {
            final List<URL> urls = new ArrayList<URL>();
            if (value != null)
            {
                for (final String segment : value.split(","))
                {
                    try
                    {
                        urls.add(new URL(segment));
                    }
                    catch (final MalformedURLException e)
                    {
                        throw new IllegalArgumentException(e);
                    }
                }
            }
            return urls;
        }
    }
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to