0

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.)

dermoritz
  • 12,519
  • 25
  • 97
  • 185

1 Answers1

1

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.

G. Demecki
  • 10,145
  • 3
  • 58
  • 58
  • thats too bad, but thanks. I came from google guice injection and guice is able to inject all classes with 0-arg constructor. – dermoritz Nov 03 '15 at 13:13
  • @dermoritz please correct me I've misunderstood you, but Guice is basically the same here. Because you still have to write a line `bind(GroupedExchangeAggregationStrategy)`, or write a one-line producer method. CDI is not different here. – G. Demecki Nov 03 '15 at 14:42
  • 2
    no if i directly inject "GroupedExchangeAggregationStrategy" if i want to inject AggregationStrategy then i have to bind. – dermoritz Nov 03 '15 at 15:54