camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Olivier.Roger" <olivier.ro...@bsb.com>
Subject [Camel-exec] dynamic parameters in Spring DSL
Date Thu, 21 Oct 2010 08:24:02 GMT

Hello,

I am using Camel version 2.4 for the new Camel-exec component.

I would like to ask your opinion on this potential improvement for the usage
of this component with Spring DSL. To use dynamic parameters the
CamelExecCommandArgs header has to be set with a Java List object.

This of course requires Java code to create (simple of course, but still).
Would it not more user friendly if it a String could be given instead/also ?
In that case a separator would be necessary but I guess a blank space could
be the default value.

This way instead of doing 

            <setHeader headerName="execArgs">
                <constant>arg1,arg2,arg3</constant>
            </setHeader>

            <setHeader headerName="CamelExecCommandArgs">
                <method bean="helper" method="parseArgs"/>
            </setHeader>

    <bean id="helper" class="CamelExecHelper">
         <property name="argsHeader" value="execArgs" />
         <property name="argsSeparator" value="," /> <!-- optional -->
    </bean>

This could be writtent 

            <!-- optional -->
            <setHeader headerName="CamelExecCommandArgs">
                <constant>,</constant>
            </setHeader>

            <setHeader headerName="CamelExecCommandArgs">
                <simple>arg1,arg2,arg3</simple> <!-- of course simple offers
many more advance possibilities -->
            </setHeader>

The bean code is very simple indeed but is required 

    public List<String> parseArgs(@Header(field) String argsHeader){
        List<String> args = new ArrayList<String>();
        
        args.addAll(Arrays.asList(argsHeader.split(argsSeparator)));

        return args;        
    }

But maybe I am not seeing an easier way already applicable with the current
version. In that case, please tell me.
-- 
View this message in context: http://camel.465427.n5.nabble.com/Camel-exec-dynamic-parameters-in-Spring-DSL-tp3230040p3230040.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message