You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by fabiolf <fa...@gmail.com> on 2012/08/25 17:13:32 UTC
How to have an aggregate field inside a composite injected by
subservice instantiate?
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-an-aggregate-field-inside-a-composite-injected-by-subservice-instantiate-tp4999009.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org