Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • How a component can provide two services
  • How to attach a service property to provided service
  • How a service property can be dynamically updated by component code
  • How to configure instances
  • How a service dependency can filter providers
  • How creating instance for a component not contained in the same bundle
  • How configuring instances

The code sources of this tutorial is available here. This tutorial used the iPOJO Eclipse plugin.

Context

This tutorial uses a very simple application. Customers use a Vendor service to buy hot dog or pop corn according to the availability of these two providers. Both the pop corn vendor and the hot dog vendor implement (and provide) the vendor service. The hot dog vendor depends on two other services for getting ingredient. It depends on a bun service and a wiener service.

image hereImage Added

Writing a component providing two services

...

In the "provides" element, two properties are added. This property contains a "field" attribute aiming to attach the service property with a field of the implementation class. Then a default value is given. In the code, the property fields will obtain the initial value (10). Then at each time the fields are modified, the service property is updated (and the OSGi™ OSGi? service registration is updated).

...