Dye357 created CAMEL-9756:
-----------------------------
Summary: It would be great if Objects returned by language
expressions could be set as the body on an Exchange without using the
LanguageProducer
Key: CAMEL-9756
URL: https://issues.apache.org/jira/browse/CAMEL-9756
Project: Camel
Issue Type: Wish
Components: camel-script
Affects Versions: 2.16.0
Reporter: Dye357
Priority: Minor
Scenario:
I would like to manipulate a file on the exchange with groovy.
However:
ScriptProcessor.java states:
* A processor which executes the script as an expression and does not change
the message body. * In this case GroovyExpression is instantiated and an Object
is returned but the returned object is ignored by obvious design.
In order to successfully manipulate a file on the exchange using groovy the
only way I have found is to explicitly declare the uri:
language:groovy:file:/<pathToScript> in a <to> block. This leverages the
languageProducer.java class which assigns the returned object from
GroovyExpression.java as the body on the Exchange.
My question(s) are:
1. Why does Script Processor intentionally not assign the result from
GroovyExpression.java to the body?
2. What is the best way in Camel to evaluate a groovy script and assign what is
returned from the groovy script to the body on the exchange (In my case a
java.io.File Object)?
3. Why does ProcessorDefintion.java not expose Language?
My objection using the URI I provided above is that I am programatically
generating my camel XML and embedding groovy script with multiple lines in a
URI is somewhat fragile & loading the groovyscript from a file is not practical
for my use case.
Thanks!!
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)