Search code examples
javacdijboss-weldweld

CDI do i need producer for objects with default constructor?


In my project i use weld se. I have a problem injecting "GroupedExchangeAggregationStrategy" into one of my constructors. This object has a default no argument constructor. Beans.xml is set to discover "all". But i get unsatisfied dependency for type GroupedExchangeAggregationStrategy.

Do i need to create a producer to just return new GroupedExchangeAggregationStrategy()? Or what else could cause the problem?

(The project already uses many @Produces and qualifiers. So the cdi stuff works in general.)


Solution

  • You are correct.

    If you need an injection of the 3rd party classes (like from Apache Camel in your case) the best way is to create a Producer method. Default scope will be @Dependent.