Hi David

> Am 18.09.2015 um 08:34 schrieb David Leangen <o...@leangen.net>:
> 
> 
> Hi Felix,
> 
> Thank you very much for this!
> 
> [  I regret that in my attempt to try to figure this out quickly I just 
> double-posted on bndtools… Bad me! :-(  ]
> 
> So, you are confirming:
> * The first time getProperties() is called, it returns null (i.e. this is 
> expected behaviour)

Yes

> * After update, getProperties() will only return the properties just set 
> (i.e. this is expected behaviour)

update(Dictionary) replaces all existing properties with your new sets of 
properties. So existing old properties are lost unless you had them in 
Dictionary.

> 
> So then, what is the right way to obtain the existing properties of a 
> component (other than the ones I just set)? I was not successful when digging 
> around the spec to find the answer.

But, as BJ on bndtools notes, if you are just a DS component, you should not be 
fiddling with ConfigAdmin and just have an activate method which gets the 
configuration injected — either as part of the ComponentContext or the 
Map<String, Object> argument to the activate method. This way you also 
guarantee that you get the default values for your properties declared in the 
descriptor which don’t exist in the configuration.

Regards
Felix

> 
> 
> Best,
> =David
> 
> 
> 
> 
>> On Sep 18, 2015, at 3:26 PM, Felix Meschberger <fmesc...@adobe.com> wrote:
>> 
>> Hi David
>> 
>>> Am 17.09.2015 um 11:29 schrieb David Leangen <o...@leangen.net>:
>>> 
>>> 
>>> Hi!
>>> 
>>> Using Felix SCR…
>> 
>> I think this is related to Felix Configuration Admin, though
>> 
>>> 
>>> I am trying to obtain a component’s properties object by:
>>> 
>>> ConfigurationAdmin cm = {obtain the cm}
>>> Configuration componentConfig = cm.getConfiguration( componentPid );
>>> componentConfig.getProperties();
>>> 
>>> I can confirm that I am getting the correct Configuration object (when I 
>>> add a property and update, it updates the component), however, I am getting 
>>> a null result when I try to obtain the properties before doing an update, 
>>> and an “incomplete” properties object after the update (containing only the 
>>> service.pid property).
>> 
>> When calling getConfiguration for the first time for a given componentPid 
>> the configuration is newly created and there are no properties. Which is why 
>> you getProperties() returns null.
>> 
>> You have to first call update(Dictionary) to set the initial configuration. 
>> After that getProperties() will return a Dictionary with the values just set.
>> 
>> Calling update() (the no arg variant) just causes the configuration to be 
>> reloaded from persistence. Yet, for a new configuration which has never been 
>> updated with update(Dictionary) this is essentially a no-op.
>> 
>> Mind you though: Calling getConfiguration(String) (the single argument 
>> variant) binds the configuration to your calling bundle context. You might 
>> want to consider using the getConfiguration(String pid, String 
>> bundleLocation) variant to create a new configuration.
>> 
>> Regards
>> Felix
>> 
>>> 
>>> Am I misunderstanding what should happen? Or is my understanding correct, 
>>> but I am for some reason not getting the correct result?
>>> 
>>> 
>>> Thanks!
>>> =David
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
>>> For additional commands, e-mail: users-h...@felix.apache.org
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
>> For additional commands, e-mail: users-h...@felix.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
> For additional commands, e-mail: users-h...@felix.apache.org
> 

Reply via email to