You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by gmagniez <ga...@steria.com> on 2009/02/09 17:15:16 UTC
TIPS: HowTo Use Producer annotations with java DSL only (no xml)
Hello,
I was looking for using @Produce and @EndpointInject annotations without
using Spring XML, but at the beginning with no success, my producer was null
all the time.
So after many and many runs of my application with differents CamelContext
parameters, i've found some which works perfect for me.
So I decided to share it because the online documentation dont explain
anywhere how to do that.
Maybe a shorter solution can be found.
So, now the Java code:
StaticApplicationContext ctx = new StaticApplicationContext();
SpringCamelContext camelContext =
SpringCamelContext.springCamelContext(ctx);
CamelBeanPostProcessor proc = new CamelBeanPostProcessor();
proc.setApplicationContext(ctx);
proc.setCamelContext(camelContext);
ctx.getBeanFactory().addBeanPostProcessor(proc);
camelContext.addRoutes(...);
camelContext.start();
--
View this message in context: http://www.nabble.com/TIPS%3A-HowTo-Use-Producer-annotations-with-java-DSL-only-%28no-xml%29-tp21916074s22882p21916074.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: TIPS: HowTo Use Producer annotations with java DSL only (no xml)
Posted by James Strachan <ja...@gmail.com>.
2009/2/9 gmagniez <ga...@steria.com>:
>
> Hello,
> I was looking for using @Produce and @EndpointInject annotations without
> using Spring XML, but at the beginning with no success, my producer was null
> all the time.
> So after many and many runs of my application with differents CamelContext
> parameters, i've found some which works perfect for me.
> So I decided to share it because the online documentation dont explain
> anywhere how to do that.
>
> Maybe a shorter solution can be found.
>
> So, now the Java code:
>
> StaticApplicationContext ctx = new StaticApplicationContext();
> SpringCamelContext camelContext =
> SpringCamelContext.springCamelContext(ctx);
> CamelBeanPostProcessor proc = new CamelBeanPostProcessor();
> proc.setApplicationContext(ctx);
> proc.setCamelContext(camelContext);
> ctx.getBeanFactory().addBeanPostProcessor(proc);
> camelContext.addRoutes(...);
> camelContext.start();
Ah great stuff.
BTW if you don't want to use XML but are using Spring, why not use
JavaConfig? e.g. here's an example of an application, route definition
and a unit test all in a single class (with an inner class for the
configuration replacing the XML)...
http://camel.apache.org/spring-java-config.html
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/