7 Replies Latest reply on Jan 28, 2016 5:49 AM by Martin Kouba

    How to dynamically build independent object trees ?

    mathieu g Newbie

      Hi all,

      I'm wondering how to use CDI to build multiple independent objects trees representing the same type of data. Here is an example:

      I have a Car, in which I want to inject GearShift and Engine.
      I also want to inject Engine in GearShift

      This Car + GearShift + Engine is my tree.

      If I want to have several cars at the same time, what would be the best way to do this using CDI?
      I would expect to be able to define a kind of scope or a qualifier for each tree. But CDI scopes and qualifiers are defined statically, while the number of cars is dynamic.

      As an additional requirement, I would like to inject another dependency that would be shared between cars. For example, all cars would share the same Road for their whole lifetime (couldn't find something else that makes more sense).

      Thanks in advance