You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by João Assunção <jo...@joaoassuncao.com> on 2008/09/24 17:00:39 UTC

Updating the configuration of a declarative service without reactivation

Hello,

Is it possible to update the configuration of a declarative service without
the reactivation?
I make this question because it seems the reactivation implies deleting the
service and creating a new one, something that is very inconvenient to me.
As a workaround, I declared in the component configuration a property named
service.pid with a value different from the component name and added the
entry <provide interface="org.osgi.service.cm.ManagedService" />.  This
seems to work, (apart the duplicate invocation of the update method when the
bundle starts), but I'm worried this might cause problems.

Thank you.

Joao

Re: Updating the configuration of a declarative service without reactivation

Posted by João Assunção <jo...@joaoassuncao.com>.
Hi Pierre,

A big thanks for your response. You have been a great help.

Best regards,
Joao

On Thu, Sep 25, 2008 at 8:03 AM, Pierre De Rop <
pierre.de_rop@alcatel-lucent.fr> wrote:

> H João;
>
> I have asked the same question, and you can refer to the following post:
>  http://www.mail-archive.com/users@felix.apache.org/msg01120.html
>
> FYI, at Alcatel-Lucent, we don't use conf admin, especially because it
> sounds like it is not possible to
> easily reconfigure SCR componenst without restarting them (and we think,
> like you, that it is an issue).
>
> We tried the same thing than you, by using a service.pid different from
> the component name, but our "updated"
> method was called twice, like in your case.
>
> So, we work around like this: we have our own configuration manager
> (which could use configadmin, but does not for now).
> And our config manager injects standard java.util.Properties objects
> into the OSGi service registry.
> So, our configurable SCR components just define references over
> Properties object, using a "config.id" keyword:
>
> For example, in the OSGi service registry, our conf manager registers a
> Properties object with "config.id=MyEnglishDictionary",
> and here is the SCR.xml for our EnlishDictionary component:
>
> <component name="EnglishDictionary">
>  <implementation class="sample.impl.dictionary.english.EnglishDictionary"/>
>
>  <reference name="Config" interface="java.util.Properties"
>   bind="bindConfig"
>   target="(config.id=MyEnglishDictionary)"
>   policy="dynamic"
>   cardinality="1..n"/>
>
>  <service>
>   <provide interface="sample.service.dictionary.Dictionary"/>
>  </service>
>  <property name="language" value="en"/>
> </component>
>
> And when the conf manager updates the Properties in the OSGi service
> registry, then the EnglishDictionary component is just invoked
> in the bindConfi() method, without being reactivated (notice the
> policy="dynamic" attribute).
>
> If someone has a better approach ... I am very interested ...
>
> Hope this helps you.
> /pierre
>
>
> João Assunção wrote:
>
>> Hello,
>>
>> Is it possible to update the configuration of a declarative service
>> without
>> the reactivation?
>> I make this question because it seems the reactivation implies deleting
>> the
>> service and creating a new one, something that is very inconvenient to me.
>> As a workaround, I declared in the component configuration a property
>> named
>> service.pid with a value different from the component name and added the
>> entry <provide interface="org.osgi.service.cm.ManagedService" />.  This
>> seems to work, (apart the duplicate invocation of the update method when
>> the
>> bundle starts), but I'm worried this might cause problems.
>>
>> Thank you.
>>
>> Joao
>>
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Updating the configuration of a declarative service without reactivation

Posted by Pierre De Rop <pi...@alcatel-lucent.fr>.
H João;

I have asked the same question, and you can refer to the following post:
   http://www.mail-archive.com/users@felix.apache.org/msg01120.html

FYI, at Alcatel-Lucent, we don't use conf admin, especially because it
sounds like it is not possible to
easily reconfigure SCR componenst without restarting them (and we think,
like you, that it is an issue).

We tried the same thing than you, by using a service.pid different from
the component name, but our "updated"
method was called twice, like in your case.

So, we work around like this: we have our own configuration manager
(which could use configadmin, but does not for now).
And our config manager injects standard java.util.Properties objects
into the OSGi service registry.
So, our configurable SCR components just define references over
Properties object, using a "config.id" keyword:

For example, in the OSGi service registry, our conf manager registers a
Properties object with "config.id=MyEnglishDictionary",
and here is the SCR.xml for our EnlishDictionary component:

<component name="EnglishDictionary">
  <implementation class="sample.impl.dictionary.english.EnglishDictionary"/>

  <reference name="Config" interface="java.util.Properties"
    bind="bindConfig"
    target="(config.id=MyEnglishDictionary)"
    policy="dynamic"
    cardinality="1..n"/>

  <service>
    <provide interface="sample.service.dictionary.Dictionary"/>
  </service>
  <property name="language" value="en"/>
</component>

And when the conf manager updates the Properties in the OSGi service
registry, then the EnglishDictionary component is just invoked
in the bindConfi() method, without being reactivated (notice the
policy="dynamic" attribute).

If someone has a better approach ... I am very interested ...

Hope this helps you.
/pierre

João Assunção wrote:
> Hello,
>
> Is it possible to update the configuration of a declarative service without
> the reactivation?
> I make this question because it seems the reactivation implies deleting the
> service and creating a new one, something that is very inconvenient to me.
> As a workaround, I declared in the component configuration a property named
> service.pid with a value different from the component name and added the
> entry <provide interface="org.osgi.service.cm.ManagedService" />.  This
> seems to work, (apart the duplicate invocation of the update method when the
> bundle starts), but I'm worried this might cause problems.
>
> Thank you.
>
> Joao
>
>   



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