« Return to Thread: List of named components as arg to constructor param

List of named components as arg to constructor param

by joe panico-2 :: Rate this Message:

Reply to Author | View in Thread

Hello,

I'm using PicoContainer 2.8.3.

I would like Pico to explicitly wire specific named (keyed) components
into a constructor arg for a List type param. For example:

class Element{
   private final String config;
   public Element(String config){
      this.config = config
   }
}

class Composition{
   private final List<Element> elements;
   public Composition(List<Element> elements){
      this.elements = elements
   }
}

pico.addComponent("elementA", Element.class, new ConstantParameter("configA"))
pico.addComponent("elementB", Element.class, new ConstantParameter("configB"))
pico.addComponent("elementC", Element.class, new ConstantParameter("configC"))

pico.addComponent("compositionAB", Composition.class, ?tell it to use
keys "elementA" + "elementB"?)
pico.addComponent("compositionBC", Composition.class, ?tell it to use
keys "elementB" + "elementC"?)

How do I achieve those last two lines of pseudo code? I don't care if
the solution is not typesafe with respect to generics.

thanks for any pointers.

Joe

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: List of named components as arg to constructor param