...
Wiki Markup |
---|
{snippet:id=invoke|lang=java|url=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/pojo/PojoRouteTest.java} |
Bean as endpoint
Camel also supports invoking Bean as an Endpoint. In the route below:
Wiki Markup |
---|
{snippet:id=e1|lang=xml|url=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/bind/beanAsEndpoint.xml} |
What happens is that when the exchange is routed to the myBean
Camel will use the Bean Binding to invoke the bean.
The source for the bean is just a plain POJO:
Wiki Markup |
---|
{snippet:id=e1|lang=java|url=activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/ExampleBean.java} |
Camel will use Bean Binding to invoke the sayHello
method, by converting the Exchange IN body to the String type and store the output of the method on the Exchange OUT body.
Bean Binding
How bean methods are chosen to be invoked (if they are not specified explicitly via the method parameter) and how parameter values are constructed from the Message are all defined by the Bean Binding mechanism which is used througout all of the various Bean Integration mechanisms in Camel.
...