2009/2/9 gmagniez <[email protected]>:
>
> 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/

Reply via email to