felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clement Escoffier <clement.escoff...@gmail.com>
Subject Re: ipojo and default values
Date Fri, 28 Oct 2011 07:49:55 GMT

On 27.10.2011, at 23:35, Bengt Rodehav wrote:

> I'm using iPOJO and have problems with default property values. Consider the
> following:
> *  @Property(name = "url", mandatory = true, value = "
> http://localhost:8093/service")*
> *  private String mUrl;*
> If I use config admin (with fileinstall) to provide an override to the "url"
> property (changing the port from 8093 to 9991), then the following happens:
> 1. My @Update method is called. The port is 8093.
> 2. My @Validate method is called. It does some initialization that can take
> a second or two. On entering the @Validate method the port is 8093.
> 3. My @Update method is called again. The port is now 9991 which means that
> this is the value from config admin. Note that my @Validate method is not
> done at this point.
> 4. My @Validate method returns. At this point the port is 9991. However, the
> initialization code in the @Validate method used the port 8093 not 9991 that
> I wanted to use.
> I expected the port 9991 to be used since I had overridden the default port
> (8093). I'm not sure why this is happening. How can I guarantee that the
> overridden port is used instead of the default port?
> Note that since the update to port 9991 takes place while I'm in my
> @Validate method I missed the update and I won't be informed about it again.

If you want to be notified after a reconfiguration, you can use @Property on a method (called
when the value is injected) or use the @Updated called when a reconfiguration occurred (and
when the reconfiguration is completed). 

@Validate is called only once (or after an invalidation).



> /Bengt

To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org

View raw message