camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Composed Message Processor example (Spring XML) doesn't work
Date Sat, 10 Mar 2012 07:40:27 GMT
Hi

You should make the method a static method on your OrderItemHelper,
as the constructor is private, which means its not possible to create
a bean instance of it

If you have a static method you need to declare the FQN of the bean in
the <method> as
with the beanType attribute for the FQN

 <method beanType="com.foo.OrderItemHelper" method="isWidget"/>


Alternative is to have a public default ctr of the helper, and then
declare it as a regular <bean>

<bean id="orderItemHelper" class="com.foo.OrderItemHelper"/>

And then refer to it using the ref attribute to its id:
 <method ref="orderItemHelper" method="isWidget"/>



On Fri, Mar 9, 2012 at 7:22 PM, Jing Yang <jyang@gojbm.com> wrote:
> By following the Composed Message Processor example (see
> http://camel.apache.org/composed-message-processor.html) ,
> I created my route as below:
> <route>
> <from uri="direct:split2"/>
>
> <bean ref="baselineMappingService" method="genreateOrderItems"/>
>        <split>
>        <simple>body</simple>
>        <choice>
>        <when>
>                <method bean="orderItemHelper" method="isWidget"/>
>                <log message="body isWidget " loggingLevel="INFO"/>
>        </when>
>        <otherwise>
>                <bean ref="myTransform" method="transform"/>
>        </otherwise>
>        </choice>
>        </split>
> </route>
>
> The beans are listed as following:
>
> public class BaselineMappingService {
>        public List<OrderItem> genreateIteratorOrderItems(@Body String body){
>                List<OrderItem> list =  new ArrayList<OrderItem>();
>                if(body.contains("A")){
>                        OrderItem item = new OrderItem();
>                        item.type="widget";
>                        list.add(item);
>
>                        OrderItem item2 = new OrderItem();
>                        item2.type="non-widget";
>                        list.add(item2);
>                }
>                return list;
>        }
>
> public class OrderItemHelper{
>        private OrderItemHelper() { }
>        public boolean isWidget(@Body OrderItem orderItem) {
>
>        System.out.println("isWidget ?" + orderItem.type.equals("widget"));
>
>        return orderItem.type.equals("widget");
>        }
> }
>
> In runtime, the org.apache.camel.component.bean.MethodNotFoundException:
> Method with name: isWidget not found on bean: demo.esb.OrderItem@437bedc6
> was thrown.
>
> Do I miss something ?
>
> -Jing
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Composed-Message-Processor-example-Spring-XML-doesn-t-work-tp5551373p5551373.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Mime
View raw message