You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by greenbean <Ke...@ngc.com> on 2010/01/01 19:26:20 UTC

Bean Binding Config In Spring XML Instead Of Annotations

Is it possible to do something similar to what is done with annotations, but
in Spring XML?

 doSomething(@Header(value = "header1") String headerValue1, @Body String
body)

Say I don't want to use Camel annotations in my POJO.  However, I would like
to bind "header1" to my headerValue1 parameter in the Spring XML
configuration (assume I will have multiple input String parameters).  I kind
of expected it to be one of the options on the bean... <to
uri="bean:testBean?method=doSomething"/>.  Say
?method=doSomething&header1=headerValue1... etc.

Is something like this possible?

Thanks.
-- 
View this message in context: http://old.nabble.com/Bean-Binding-Config-In-Spring-XML-Instead-Of-Annotations-tp26987217p26987217.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Bean Binding Config In Spring XML Instead Of Annotations

Posted by Claus Ibsen <cl...@gmail.com>.
On Sat, Jan 2, 2010 at 7:05 PM, greenbean <Ke...@ngc.com> wrote:
>
> Are parameter indexes currently supported in the XML?  I looked around the
> examples and source code for the bean component, and could not find it.
> There is a ParameterInfo class, but I am not sure if that can be constructed
> based on input from DSL.
>

No its not.

You can use some intermediate bean and do the bean binding yourself.
eg bean A -> bean B (the intended target) if bean B cannot have any
Camel annotations.



>
>
>
> Claus Ibsen-2 wrote:
>>
>>
>> No its not possible. And if I recall correctly Java reflection cannot
>> get parameter names, so you either need to use parameter index or
>> annotations to bind them.
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Bean-Binding-Config-In-Spring-XML-Instead-Of-Annotations-tp26987217p26995134.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Bean Binding Config In Spring XML Instead Of Annotations

Posted by greenbean <Ke...@ngc.com>.
Are parameter indexes currently supported in the XML?  I looked around the
examples and source code for the bean component, and could not find it. 
There is a ParameterInfo class, but I am not sure if that can be constructed
based on input from DSL.




Claus Ibsen-2 wrote:
> 
> 
> No its not possible. And if I recall correctly Java reflection cannot
> get parameter names, so you either need to use parameter index or
> annotations to bind them.
> 
> 

-- 
View this message in context: http://old.nabble.com/Bean-Binding-Config-In-Spring-XML-Instead-Of-Annotations-tp26987217p26995134.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Bean Binding Config In Spring XML Instead Of Annotations

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jan 1, 2010 at 7:26 PM, greenbean <Ke...@ngc.com> wrote:
>
> Is it possible to do something similar to what is done with annotations, but
> in Spring XML?
>
>  doSomething(@Header(value = "header1") String headerValue1, @Body String
> body)
>
> Say I don't want to use Camel annotations in my POJO.  However, I would like
> to bind "header1" to my headerValue1 parameter in the Spring XML
> configuration (assume I will have multiple input String parameters).  I kind
> of expected it to be one of the options on the bean... <to
> uri="bean:testBean?method=doSomething"/>.  Say
> ?method=doSomething&header1=headerValue1... etc.
>
> Is something like this possible?
>

No its not possible. And if I recall correctly Java reflection cannot
get parameter names, so you either need to use parameter index or
annotations to bind them.


> Thanks.
> --
> View this message in context: http://old.nabble.com/Bean-Binding-Config-In-Spring-XML-Instead-Of-Annotations-tp26987217p26987217.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Bean Binding Config In Spring XML Instead Of Annotations

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

I don't think current Camel bean binding[1] supports this spring 
configure feature, and URI options for method parameters the m is not a 
type safe way.
If you don't want to use the annotation on the POJO method, you can use 
the Exchange as the POJO method parameter, but it still makes your POJO 
depends on the camel-core.

[1]http://camel.apache.org/bean-binding.html

Willem

greenbean wrote:
> Is it possible to do something similar to what is done with annotations, but
> in Spring XML?
> 
>  doSomething(@Header(value = "header1") String headerValue1, @Body String
> body)
> 
> Say I don't want to use Camel annotations in my POJO.  However, I would like
> to bind "header1" to my headerValue1 parameter in the Spring XML
> configuration (assume I will have multiple input String parameters).  I kind
> of expected it to be one of the options on the bean... <to
> uri="bean:testBean?method=doSomething"/>.  Say
> ?method=doSomething&header1=headerValue1... etc.
> 
> Is something like this possible?
> 
> Thanks.