Bean LanguageThe purpose of the Bean Language is to be able to implement an Expression or Predicate using a simple method on a bean. So the idea is you specify a bean name which will then be resolved in the Registry such as the Spring ApplicationContext then a method is invoked to evaluate the Expression or Predicate. If no method name is provided then one is attempted to be chosen using the rules for Bean Integration; using the type of the message body and using any annotations on the bean methods. The Bean Integration rules are used to bind the Message Exchange Using Bean Expressions from the Java DSLfrom("activemq:OrdersTopic"). filter().method("myBean", "isGoldCustomer"). to("activemq:BigSpendersQueue"); Using Bean Expressions from XML<route> <from uri="activemq:OrdersTopic"/> <filter> <methodCall bean="myBean" method="isGoldCustomer"/> <to uri="activemq:BigSpendersQueue"/> </filter> </route> Writing the expression beanThe bean in the above examples is just any old Java Bean with a method called isGoldCustomer() that returns some object that is easily converted to a boolean value in this case, as its used as a predicate. So we could implement it like this... public class MyBean { public boolean isGoldCustomer(Exchange exchange) { ... } } We can also use the Bean Integration annotations. For example you could do... public boolean isGoldCustomer(String body) {...} or public boolean isGoldCustomer(@Header(name = "foo") Integer fooHeader) {...} So you can bind parameters of the method to the Exchange Other examplesWe have some test cases you can look at if it'll help
|