Hello Oliver,

some functionality that could help you already exist in the Camel exec 
component. 

To use the component conveniently,  you can use the "args" endpoint 
argument with whitespace separator, as described in the documentation  
http://camel.apache.org/exec.html. 

You can not however achieve everything with the current implementation of 
the argument parsing,  for example the parsing has no support for nested " 
symbols. The implementation of the commons-exec library, that is the 
default implementation used by the component,, does not provide a perfect 
argument parsing algorithm that can be reused as well.

I personally prefer and use the list argument, because my code is less 
error-prone when someone else, who has not read the component 
documentation, decides to change and/or add an argument. 


Regards, 
Mitko






From:
"Olivier.Roger" <[email protected]>
To:
[email protected]
Date:
21.10.2010 10:24
Subject:
[Camel-exec] dynamic parameters in Spring DSL




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.




   
InterComponentWare AG:  
Vorstand: Peter Kirschbauer (Vors.), Jörg Stadler  
Aufsichtsratsvors.: Prof. Dr. Christof Hettich  
Firmensitz: 69190 Walldorf, Altrottstraße 31  
AG Mannheim HRB 351761 / USt.-IdNr.: DE 198388516  

Reply via email to