0

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,

HNT
  • 147
  • 1
  • 10

1 Answers1

0

You can manipulate the service binding using interceptors: http://felix.apache.org/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/ipojo-advanced-topics/service-binding-interceptors.html

With interceptors, you can hide services, and / or sort the service providers in order to enforce the provider you want to use.

Clement
  • 2,817
  • 1
  • 12
  • 11
  • Thank you for your reply. can i implement this interceptor as a independent component which control dynamically service binding manipulation ? i read your link and examples on the web https://github.com/apache/felix i don't understand how interceptor can effect to existing bundles (for change requiring service of bundle). Regards, – HNT Nov 06 '14 at 11:34
  • Interceptors are individual components, so they can be developed and deployed independently from the application. They target 'service dependencies' using their 'target' property. This property is a LDAP filter selecting the dependencies you want to handle. For instance: (dependency.id=foo) selects the dependency with id foo, while (dependency.specification=org.acme.Foo) selects all dependencies requiring the org.acme.Foo service interface. – Clement Nov 08 '14 at 08:01