Hi, Just add 'aggregate="true" to the instantiate directive:
> <subservice action="instantiate" > specification="org.apache.comanche.services.RequestHandler" aggregate="true" > /> > </composite> Regards, Clement On 25 août 2012, at 17:11, fabiolf <[email protected]> wrote: > Hello all, > > I'm trying to create an iPOJO composite that is a little bit tricky for me. > So I decided it is time to ask for help. > > In this composite I have an instance of a component described by the XML > above: > > <ipojo> > <component > classname="org.apache.comanche.requestDispatcher.RequestDispatcher"> > <provides/> > <requires field="rh" aggregate="true" > specification="org.apache.comanche.services.RequestHandler"/> > </component> > </ipojo> > > This component has a field that is an aggregate, so I want iPOJO to > instantiate all other components which implements the RequestHandler > interface and inject all of them into this array field. To do so, I created > the composite above: > > <ipojo> > <composite name="comanche.requestHandler"> > <instance > component="org.apache.comanche.requestDispatcher.RequestDispatcher"> > <property name="instance.name" value="RequestDispatcher"/> > </instance> > <subservice action="instantiate" > specification="org.apache.comanche.services.RequestHandler" /> > </composite> > <instance component="comanche.requestHandler"> > <property name="instance.name" value="RequestHandlerComposite"/> > </instance> > </ipojo> > > Regarding the components that implement the RequestHandler interface, I > currently have two of them: > > <ipojo> > <component > classname="org.apache.comanche.requestHandlers.ImageRequestHandler"> > <provides/> > </component> > <component > classname="org.apache.comanche.requestHandlers.ErrorRequestHandler"> > <provides/> > </component> > </ipojo> > > So, I was hoping that when I instantiate the composite, the "subservice > action instantiate" would find all my RequestHandlers and inject them into > my RequestDispatcher rh field. But when I run it, the framework chooses just > one RequestHandler component instead of injecting every one. > > It it possible to achieve what I want? How can I do it? Maybe there is a way > to tell subservice action instantiate to instantiate all components instead > of just the first one? > > Thanks, > Fabio > > > > > -- > View this message in context: > http://apache-felix.18485.n6.nabble.com/How-to-have-tp4999008.html > Sent from the Apache Felix - Users mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

