Annotation Based Expression Language
Advanced example using @Bean
And then we can have a spring bean with the id myCorrelationIdGenerator where we can compute the id.
The POJO MyIdGenerator has one public method that accepts two parameters. However we have also annotated this one with the @Header and @Body annotation to help Camel know what to bind here from the Message from the Exchange being processed.
Of course this could be simplified a lot if you for instance just have a simple id generator. But we wanted to demonstrate that you can use the Bean Binding annotations anywhere.
And finally we just need to remember to have our bean registered in the Spring Registry:
Example using Groovy
In this example we have an Exchange that has a User object stored in the in header. This User object has methods to get some user information. We want to use Groovy to inject an expression that extracts and concats the fullname of the user into the fullName parameter.
Groovy supports GStrings that is like a template where we can insert $ placeholders that will be evaluated by Groovy.