On 04.05.2009, at 15:59, André Lage wrote:
Hi Clement,
Clement Escoffier wrote:
Hi,
On 04.05.2009, at 15:14, André Lage wrote:
Hello,
I am a new iPOJO/Felix user and I am using it to implement a
simple case study. Let's suppose that there are 10 providers
(called provider #1, provider #2, ..., provider #10) that offer
the same service, each one is a bundle composed by one component.
The consumer (another bundle composed by a single component) can
*only* "trust" in two of them, provider #1 and provider #2. So it
only accepts them as providers.
I read in [1] that I can target a specific provider by using the
*from* attribute as follows:
<component classname="...HelloConsumer">
<requires from="MyHelloProvider">
<callback type="bind" method="bindHello">
<callback type="unbind" method="unbindHello">
</requires>
...
</component>
However, I need to target *either* the provider #1 *or* the
provider #2. I did it by filtering the provider writing a method
in the POJO code, but I would like to let the handler addresses it
for me. So here are my questions:
1) How could I do it by just modifying/tuning my metadata.xml file
(i.e., by letting the handler addresses it for me)?
2) If it is possible, could I also specify something like to
target *both* the provider #1 *and* the provider #2?
You can filter the providers. Imagine that the provider have a
service property indicating their names.
Your metadata will be:
<requires filter="(|(provider.name=provider#1)
(provider.name=provider#2))" aggregate="true">
<callback type="bind" method="bindHello">
<callback type="unbind" method="unbindHello">
</requires>
If you specify instance names like in
<instance component"..." name="provider#1"/>
So, iPOJO registers a service property for you ("instance.name"),
so your service dependency will look like:
<requires filter="(|(instance.name=provider#1)
(instance.name=provider#2))" aggregate="true">
<callback type="bind" method="bindHello">
<callback type="unbind" method="unbindHello">
</requires>
It perfectly worked, thanks!
In this case, I realized that the consumer is satisfied if at least
*one* of these two providers is available. I would like also to tune
another service consumer in such a manner that it needs *both*
providers #1 and #2 available. Is it possible?
You can have two requirements (they can use the same bind/unbind
method) such as:
<requires filter="(provider.name=provider#1)">
<callback type="bind" method="bindHello">
<callback type="unbind" method="unbindHello">
</requires>
<requires filter="(provider.name=provider#2)">
<callback type="bind" method="bindHello">
<callback type="unbind" method="unbindHello">
</requires>
Regards,
Clement
--
André Lage Freitas
Regards,
Clement
Thank you in advance,
--
André Lage Freitas
[1]
http://felix.apache.org/site/service-requirement-handler.html#ServiceRequirementHandler-Targetingaspecificprovider
---------------------------------------------------------------------
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]
---------------------------------------------------------------------
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]