A couple comments (fast, low quality, and cheap) I believe you want to @Autowire annotate your producer template (and I'd think you need the @Produce as a class level annotation, though I mostly use XML configuration)
Wiring up a Singleton in a route is IMHO more easily/clearly done in Spring/Blueprint XML (where Singleton is the default). Hope that helps Cheers, Hans Pardon the brevity, Sent from my phone On Jul 6, 2015 6:37 AM, "Benjamin Legendre" <[email protected]> wrote: > Hi, > I'm using Camel 2.15.2 inside a stand alone java application. > > I do not figure how to add a bean in the Camel context in order to inject > a ProducerTemplate using @Produce on a property of my bean. > I my scenario The producer is not injected. > > > Here is the bean binding: > > SimpleRegistry registry = new SimpleRegistry(); > registry.put("dtsm", new DigitalTimeSeriesNormalizer()); > CamelContext context = new DefaultCamelContext(registry); > > > The bean is then called like this is the route: > > .beanRef("dtsm", "normalize") > > > Here is the code inside the bean: > > public class DigitalTimeSeriesNormalizer { > > @Produce > public ProducerTemplate producerTemplate; > > [...] > > public ArrayList<TimeSerie> normalize(ArrayList<TimeSerie> timeSeries) > { > > this.producerTemplate // is null here > > [...] > } > > It works when i use this syntax: > > .bean(DigitalTimeSeriesNormalizer.class, "normalize") > > But it is not what i want because a new instance of the bean is created > each time it is called on the route. > If this is the only way to make it to work, is there a way to make camel > instanciate it only one time and use a reference of the bean the next time ? > > Thanks in advance. > Benjamin >
