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

Reply via email to