0

I'm currently running the Equinox OSGi container from within Eclipse to test and run my Bundle.
I'm looking for the simplest way to pass some runtime parameters to my bundle. The standard way would be to use the ConfigurationAdmin to configure my bundle.

Is there a way to use the Launch Configuration "Arguments" tab to set some properties such that ConfigurationAdmin would pass them to my bundle?

Here is what I tried to do:

On Eclipse documentation I found that properties could be set by setting Java VM argumets:

Properties can be set in the following ways:

  • use -DpropName=propValue as a VM argument to the Java VM
  • set the desired property in the config.ini file in the appropriate configuration area

So I registered my ManagedService with props.put("service.pid","test"); then added a -Dtest.value=1 VM argument on my Launch Configuration.
Unfortunately this doesn't work: updated function is called only with null props (as expected) but not called again with my value=1 property.

Any Idea?

Amir Gonnen
  • 3,525
  • 4
  • 32
  • 61
  • You access something set with `-dname=value` using `System.getProperty(name)` – greg-449 Jan 22 '14 at 07:49
  • Yes, this works. But I wonder if there is a way to pass properties to `ConfigurationAdmin`, which is the standard way to configure an OSGi bundle. – Amir Gonnen Jan 22 '14 at 08:04
  • You may want to have a look at [this](http://www.avineas.org/index.php?page=cm-persister) bundle. – Arie van Wijngaarden Jan 22 '14 at 13:07
  • @ArievanWijngaarden That bundle allows specifying properties in property files. This is a possible solution, but I'm looking for a way to set properties directly from command line (or Eclipse Launch Configuration). I guess I could write a bundle that does it, but perhaps someone already did it. – Amir Gonnen Jan 23 '14 at 07:09

0 Answers0