I have an example relating my problem. (files joint: https://drive.google.com/file/d/0B8ThLrV6-uchaFlTZTNGQ1FnT1E/view?usp=sharing )
I have 3 ipojo components (3 bunbles):
CallHello uses a DelayService service which implemented in both HelloDelay or HelloComponentReplace
HelloDelay and HelloComponentReplace use a HelloService service which implemented in HelloPrint.
At deployment, I deploy 5 bundles:
service.hello.service.jar
printer.hello.printer.jar
delay.hello.delay.jar
replace.hello.replace.jar
call.hello.call.jar
Result: DelayService uses always the implementation in HelloDelay.
Finally, I run Main.java to control manually selection between HelloDelay and HelloComponentReplace.
I implemented a function to start/stop or uninstall/install bundles in Main.java (and it works well). However, either HelloDelay or HelloComponentReplace is valid.
In the case both is active and valid, i read on the iPOJO website and I can use “comparator”. But I don’t understand how to apply ‘comparator’ to control selection between 2 components above. Is this to change priority? I know that we can change priority of bundle but I cannot know how to apply to my file (Main.java) and iPOJO.
Could we control connection (binding) between a requiring component and many providing components (same service or interface)?
I hope that you could help my difficulty in this time.
Best regards,