Hello!

I use iPOJO (1.4.0) and File Install (3.0.0) deployed on Karaf (1.6.0).

I use the service factory pattern in OSGi to instantiate services from
configuration files picked up by File Install. Howrver, there seems to be a
startup problem. When the service is originally started, not all properties
(in my newly instantiated service have received their values from the
configuration file). Using Felix web console (the Configuration tab) the
property values are correct. However, when I look under the iPOJO tab on the
created instances the values are wrong. If I do any change in my
configuration file (e g add some whitspace) and save it, File Install picks
up the change and the iPOJO instance is now configured with the correct
value.

I've seen a pattern regarding this. It seems like properties that are not
given a default value in my code (initialised to null) will get their
configuration set properly but the properties that are initialised to
another value than null will not get their proper value until I later
re-save my configuration file (which I guess is the next time File Install
will propagate configuration changes).

Given the following code in my iPOJO service:

...
  @Property(name = "toUri", mandatory = false)
  private String mToUri;

  @Property(name = "delay", mandatory = false)
  private long mDelay = 1000;
...

The "toUri" property will be initialised properly when the service is
started but the "delay" property will be initialised to 1000 regardless of
what value I put in the configuration file. When I later re-save the
configuration file, the proper value of the "delay" property will be
propagated.

How can I have a default value but still have it overridden properly?

/Bengt

Reply via email to