You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by bgoetzmann <bg...@sophia.symag.com> on 2007/09/21 16:38:22 UTC

Camel and Groovy

Hello,

In a test (that works), I can use the Groovy language in an Expression:

CamelContext camelContext = new DefaultCamelContext();
				
		final GroovyExpression gexpr = new GroovyExpression("exchange.in.body.name
== 'test1.txt'");
		
		camelContext.addRoutes(new RouteBuilder() {

		    public void configure() {
		    	from("file:test?regexPattern=test.*&delete=true")		        
		        .filter(gexpr)		  
		        .setBody(body().append(" traité !"))
		       
.to("smtp://bgoetzmann@srvmailsophia?password=CloudStack#bgoetzmann@sophia.symag.com");		        
		    }
		    
		});
		
		camelContext.start();

...

In this test, where we poll a folder named test to detect files with name
begining with 'test', the Groovy expression is used to filter messages and
keep messages containing a File object (as body) with a name equals to
'test1.xml'.
All is OK.

Groovy is powerful language! So, I suppose I can put a lot of Groovy code in
a String. Is a way to execute Groovy code taken from a file, for example to
manipulate the content of my XML file?


Thank you.

Bertrand.
http://www.odelia-technologies.com/
-- 
View this message in context: http://www.nabble.com/Camel-and-Groovy-tf4496606s22882.html#a12822937
Sent from the Camel - Users mailing list archive at Nabble.com.