Annotation Based Expression LanguageYou can also use any of the Languages supported in Camel to bind expressions to method parameters when using Bean Integration. For example you can use any of these annotations:
Example:Advanced example using @BeanAnd an example of using the the @Bean binding annotation, where you can use a POJO where you can do whatever java code you like: 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 GroovyIn 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. |