tags:

views:

36

answers:

2

In the end i will perhaps provide a helper so that the activator can import and export services and other types of meta data about the system.

By parameters i mean objects in general, perhaps via a map. it would be great if one bundle when installing another had a mechanism to send parameters to the starting bundle. I suppose i could include a service on the later bundle and use it as a configuration service but that seems a bit unelegant.

+2  A: 

If you want to "send" some configuration parameters to a starting bundle you can use standard OSGi services like Configuration Admin Service. If you want to pass around arbitrary objects you should probably use OSGi service registry.

Could you please clarify your question? What you mean by "host" bundle and "embedded" bundle? What kind of "helper" do you want to provide? Most importantly what kind parameters you want to pass from one bundle to another?

Pavol Juhos
The stuff i wished to send would be a combination of pojos and another services.
mP
Host = the OSGi service providing config, Embedded = service consuming the parameters and offering other services.
mP
A: 

To do (pre-) runtime configuration of a bundle, you should use the Configuration Admin Service. For pojos etc you can follow this pattern:

  • Bundle A installs and starts Bundle B
  • Bundle B registers a "configuration" service, e.g. with the interface acme.ConfigureB.
  • Bundle A tracks services with the interface acme.ConfigureB.
  • Whenever A receives the tracker callback for acme.ConfigureB it does all the necessary configurations.
akr
Seems kinda leeky, B now need to include code just to init itself. I need to readup and better understand Config Admin Service before i can select an answer.
mP
You need to be aware that in OSGi bundles A or B can be started in any order. So B can be installed and started before A is installed, and vice versa. You should always follow the White Board pattern (see OSGi Spec): don't make any assumption that another bundle or service is started before another or is even present. It is a bit hard to grasp in the beginning, but you will end up with a much better design. Don't do dependency hard-coding.
akr