camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gershaw, Geoffrey" <geoffrey.gers...@credit-suisse.com>
Subject RE: Passing parameter values to bean methods via spring
Date Wed, 01 Feb 2012 14:05:24 GMT
Thanks for the reply. Could you give me an example for 1c? I mocked up an example. Assume the
below  XML comes from the ftp site. The XMLFilter's match method accepts the username. How
can I use XPath to pass the user to the match method? 


 <Example>

                <User>joe</User>

 </Example>

Class XMLFilter{

	public boolean match(String username){
		//check db for user
		//if found return true/else false
	}
}

	<route>
		<from>"ftp://rider.com/orders?username=rider&password=secret"</from>
		<filter>
			<simple>${bean:xmlFilter?method=match}</simple>
			<to uri="log:worked"/>
		</filter>
	</route>

Thanks

-----Original Message-----
From: Claus Ibsen [mailto:claus.ibsen@gmail.com] 
Sent: Wednesday, February 01, 2012 3:20 AM
To: users@camel.apache.org
Subject: Re: Passing parameter values to bean methods via spring

Hi

On Tue, Jan 31, 2012 at 5:10 PM, Gershaw, Geoffrey
<geoffrey.gershaw@credit-suisse.com> wrote:
> Hello,
>
>
>
> I am a newbie to Camel. I've read a bunch of docs, but have not found an
> answer to this specific use case.
>

Welcome to the community.

>
>
> 1.       Assume the following.
>
> a.       I have the belown XML msg in the body of my Message.
>
> <Example>
>
>                <User>joe</User>
>
> </Example>
>
> b.      I am using a bean as a Filter. The method signature is
>
>                                                          
    i.
> public boolean validateUser(String user)
>
> c.       Ideally I would like to user xpath in the config file to pass
> "Joe" to the validateUser method
>

Yes xpath works fine for grabbing content from a XML doc.
However  where it get tricky is if your XML uses namespaces. If so
your XPath expression *must* also use namespaces.


> d.      If the method returns false, I would like the route to stop.
> Don't know how to do this.
>

You can use a Content Based Router, and in the otherwise leg, you can
use the stop DSL.


> e.      If the method returns true, I would like to pass the original
> XML msg to a processor and finish the route.
>

Yes this happens already, the filter predicate is just for determine
true | false

> f.        Is this possible?
>
>

Yes, something a like

from X
  choice
     when bean (myFilterBean)
       to Y
    otherwise
      stop



>
>
>
> Thanks
>
> Geoff Gershaw
>
>
> ===============================================================================
> Please access the attached hyperlink for an important electronic communications disclaimer:
> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
> ===============================================================================
>



-- 
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/

=============================================================================== 
Please access the attached hyperlink for an important electronic communications disclaimer:

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html 
=============================================================================== 


Mime
View raw message