On Tue, Mar 31, 2009 at 12:37 PM, Martin Gilday <[email protected]> wrote:
> Thanks, we will give those a try.
>
> As your suggestions seem to differ from what I quoted I am still
> interested in what the docs are referring to here
> http://camel.apache.org/type-converter.html  Any ideas what it means by
> plugging in an Injector?  I'll try and update the wiki if this section
> is incorrect.
The type converters methods can be either static or non static. Most
of them are static.

And if I recall Camel uses the Injector to create the non static
classes, that esentially is Spring.
But if it does the full monty applying post construct annotations and
stuff I can be in doubt.

But we could add a test in camel-spring that has a custom type
converter with Spring @Resource annotations
and see if we can get it working out of the box.

Feel free to work with it a bit and get back with findings. Then we
can see what the gap is and maybe add/fix it and
improve the documentation.

All the camel related type converters do not use Spring @annotations
hence we havent been in need of it.



>
>
> ----- Original message -----
> From: "Claus Ibsen" <[email protected]>
> To: [email protected]
> Date: Tue, 31 Mar 2009 12:04:27 +0200
> Subject: Re: Type converters with Spring
>
> Hi
>
> Or pass in Exchange as the 2nd parameter.
> Using Exchange you can get hold on the CamelContext and thus the
> registry as well, and do lookup for Spring beans.
>
>
>
> On Tue, Mar 31, 2009 at 12:01 PM, James Strachan
> <[email protected]> wrote:
>> 2009/3/31 Martin Gilday <[email protected]>:
>>> I'd like to have a converter which uses a Spring @service to do lookups.
>>>  According to the docs "If a converter requires configuration you can
>>> plug in an Injector interface to the DefaultTypeConverter which can
>>> construct and inject converter objects via Spring or Guice."
>>>
>>> I'm unsure what it means by working with the DefaultTypeConverter. Are
>>> there any examples which show how to do this?
>>
>> You could try something like this
>>
>> public class MyServiceConverter implements ApplicationContextAware {
>>  ApplicationContext context;
>>
>> �...@converter
>>  public MyType convert(String name) {
>>   return context.getbean(name, MyType.class);
>>  }
>> }
>>
>> letting spring do whatever dependency injection you require on the
>> converter object
>>
>> --
>> James
>> -------
>> http://macstrac.blogspot.com/
>>
>> Open Source Integration
>> http://fusesource.com/
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> Apache Camel Reference Card:
> http://refcardz.dzone.com/refcardz/enterprise-integration
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration

Reply via email to