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

Daniel Kulp commented on CXF-5362:
----------------------------------


Most likely, all we need to do is update:

{code:java}
    public void setServiceBeans(List<Object> beans) {
        serviceFactory.setResourceClassesFromBeans(beans);
    }
{code}
to something like:
{code:java}
    private void addToBeans(Collection<Object> beans, Object o) {
            if (o instanceof Collection) {
                for (Object o2: (Collection)o) {
                    addToBeans(beans, o2);
                }
            } else {
                beans.add(o);
            }
    }
    public void setServiceBeans(List<Object> beans) {
        List<Object> newBeans = new ArrayList<Object>();
        addToBeans(newBeans, beans);
        serviceFactory.setResourceClassesFromBeans(beans);
    }    
{code}

That would allow nested lists of beans from the parsed serviceBeans element.   
Thus the format of something like:
{code:xml}
<jaxrs:server>
        <jaxrs:serviceBeans>
                <myNameSpace:doSomethingComplicated/>
        </jaxrs:serviceBeans>
</jaxrs:server>
{code}
would work fine allowing myNameSpace:doSomethingComplicated  to evaluate to 
either a single bean or a collection of beans to use for the serviceBeans.

> Spring jaxrs scheme and bean definition parser must allow alternative 
> property setting
> --------------------------------------------------------------------------------------
>
>                 Key: CXF-5362
>                 URL: https://issues.apache.org/jira/browse/CXF-5362
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAX-RS
>            Reporter: Ivan Bondarenko
>
> http://cxf.apache.org/schemas/jaxrs.xsd scheme in conjunction with 
> JAXRSServerFactoryBeanDefinitionParser class must allow alternative property 
> set.
> For example to set 'serviceBeans' now one must write:
> {code}<jaxrs:server>
>       <jaxrs:serviceBeans>
>               <ref bean="bean1"/>
>               ...
>               <ref bean="beanN"/>
>       </jaxrs:serviceBeans>
> </jaxrs:server>{code}
> However there is no way to set this if number and set of beans is unknown 
> beforehand (in case of different configurations etc).
> The easiest and most non-breaking way I see is to allow in scheme the default 
> bean tags everywhere properties can be set. So user can do e.g. following:
> {code}<jaxrs:server>
>       <property name="serviceBeans">
>               _something_here_
>       <property>
> </jaxrs:server>{code}
> Thus user can put almost anything (probably calculated in a complicated way) 
> into 'serviceBeans' (and other properties).



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to