You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by lb <lb...@gmail.com> on 2013/11/27 16:21:14 UTC

Re: ConfigAdmin and OSGi Blueprint

Hi,
I've used the suggested approach to inject the whole map:

<cm:property-placeholder id="myConfig" persistent-id="my.service.pid">
</cm:property-placeholder>

<bean id="my.bean.id" class="my.bean.Class">
    <property name="config" ref="myConfig"/>
</bean>

But the injected object is an instance of CmPropertyPlaceholder: is there a
way to inject a plain Map/Dictionary/Properties ?

Thx




On Wed, Oct 30, 2013 at 6:03 PM, Johan Edstrom <se...@gmail.com> wrote:

> You'd need to listen for config changes or ensure that you have update
> hooks or perhaps use a ManagedServiceFactory
>
> Sent from my pressure cooker.
>
> On Oct 29, 2013, at 10:37, Christian Schneider <ch...@die-schneider.net>
> wrote:
>
> I would keep the update strategy reload. As far as I know it is the only
> way to keep up to date with config changes.
>
> Christian
>
> Am 29.10.2013 13:45, schrieb lb:
>
> reload is something left from copy-and-past :-)
>
>  thx for the hint.
> —
> lb
>
>
>  On Tue, Oct 29, 2013 at 1:12 PM, Christian Schneider <
> chris@die-schneider.net> wrote:
>
>> On 29.10.2013 11:59, lbu wrote:
>> > Hi,
>> > I'm trying to figure-out which is the best option to configure a bean
>> > instantiated via OSGi Blueprint and I have a some question for which I
>> > haven't found the answer:
>> >
>> > 1) is there any way to reference to the cm:property-placeholder's
>> > persistent-id? So I can write something like:
>> >
>> > <cm:property-placeholder persistent-id="my.service.pid"
>> > update-strategy="reload">
>> > </cm:property-placeholder>
>> >
>> > <bean id="my.bean.id" class="my.bean.Class">
>> > <property name="servicePid" value="${persistent-id}"/>
>> > </bean>
>> The persistent id is reflected as property ${service.pid}
>> > 2) is there any way to have the ConfigAdmin to call Class.update(Map
>> ...)
>> > when the bean is instantiated?
>> >
>> > <cm:property-placeholder persistent-id="my.service.pid"
>> > update-strategy="reload">
>> > </cm:property-placeholder>
>> >
>> > <bean id="my.bean.id" class="my.bean.Class">
>> > </bean>
>> >
>> > class my.bean.Class {
>> > public void update(Map configuration) {
>> > ....
>> > }
>> > }
>> >
>> > thx - Luca
>>
>> Reload means that the whole context is reloaded when the config changes.
>> So it is not really an update but you can inject the whole map.
>>
>> <cm:property-placeholder id="myConfig" persistent-id="my.service.pid"
>> update-strategy="reload">
>> </cm:property-placeholder>
>>
>> <bean id="my.bean.id" class="my.bean.Class">
>> <property name="config" ref="myConfig"/>
>> </bean>
>>
>>
>> Christian
>>
>>
>> --
>> Christian Schneider
>> http://www.liquid-reality.de
>>
>> Open Source Architect
>> http://www.talend.com
>>
>>
>
>
> --
>
> Christian Schneiderhttp://www.liquid-reality.de
>
> Open Source Architect
> Talend Application Integration Division http://www.talend.com
>
>