...
You 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:
Annotation | Description |
---|---|
Inject a Bean expression | |
Inject a BeanShell expression | |
Inject a Constant expression | |
Inject an EL expression | |
Inject a Groovy expression | |
Inject a Header expression | |
Inject a JavaScript expression | |
Inject a MVEL expression | |
Inject an OGNL expression | |
Inject a PHP expression | |
Inject a Python expression | |
Inject a Ruby expression | |
Inject an Simple expression | |
Inject an XPath expression | |
Inject an XQuery expression |
...
And an example of using the the @Bean binding annotation, where you can use a POJO where you can do whatever java code you like:
...
Code Block | ||||
---|---|---|---|---|
| ||||
<bean id="myCorrelationIdGenerator" class="com.mycompany.MyIdGeneratorMySimpleIdGenerator"/> |
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.
Code Block |
---|
public void doSomething(@Groovy("$request.in.header['familiyNameuser'].firstName $request.in.header['firstNameuser'].familyName) String fullName, @Body String body) { // process the inbound message here } |
...