camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bgoetzmann <bgoetzm...@sophia.symag.com>
Subject Camel and Groovy
Date Fri, 21 Sep 2007 14:38:22 GMT

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.


Mime
View raw message