You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Bengt Rodehav <be...@rodehav.com> on 2010/03/15 19:46:16 UTC

managed-service-factory but no callback on configuration changes

Hello everyone,

I'm trying to use Spring-DM's support for managed-service-factory. My
artifact (deployed in Karaf 1.4) contains the following XML snippet in
beans.xml:

<osgix:managed-service-factory id="test-container"
factory-pid="se.digia.connect.routes.test.container"
    update-strategy="bean-managed" update-method="configurationUpdate">
    <osgix:interfaces>
      <value>se.digia.connect.core.api.IService</value>
    </osgix:interfaces>
    <bean
class="se.digia.connect.routes.test.container.impl.TestContainer"/>
  </osgix:managed-service-factory>

I then drop a configuration file called
"se.digia.connect.routes.test.container-first.cfg" in the etc folder. This
causes a service containing the correct configuration to be started and
registered. Via Felix WebConsole I can see the configuration and it's the
correct one. When I delete the configuration file from the "etc" folder, the
service is stopped. It all works.

However, my bean (an instance
of se.digia.connect.routes.test.container.impl.TestContainer) never gets a
callback. I expected the "configurationUpdate()" method of the TestContainer
class to be called whenever the configuration changes. My callback method
has the following signature:

  public void configurationUpdate(Map<String, ?> theProperties) throws
Exception

When I use a "managed-properties" instead of "managed-service-factory" I do
get the callback. The following works perfectly:

  <bean id="testRoute" class="se.digia.connect.routes.test.impl.TestRoute">
    <osgix:managed-properties persistent-id="se.digia.connect.routes.test"
update-strategy="bean-managed"
      update-method="configurationUpdate" />
  </bean>

  <spring-osgi:service ref="testRoute"
interface="se.digia.connect.core.api.IService"/>

What am I missing? How can I get a notification callback when the
configuration is changed when using a managed-service-factory?

Happy for any clues you may have.

By the way is this the recommended way to use managed service factories? Are
there any other (non Spring-DM) ways of doing this? IPojo for example.

/Bengt

Re: managed-service-factory but no callback on configuration changes

Posted by Bengt Rodehav <be...@rodehav.com>.
You're absolutely right  - my fingers slipped. I sent it to the Felix
users mailing list but maybe I should try Spring-DM as well.

/Bengt

2010/3/16 Willem Jiang <wi...@gmail.com>:
> Hi,
>
> I think you may ask this question in Spring-DM, or Karaf mailing list.
> As the question is out of scope of Camel :)
>
> Willem
>
> Bengt Rodehav wrote:
>>
>> Hello everyone,
>>
>> I'm trying to use Spring-DM's support for managed-service-factory. My
>> artifact (deployed in Karaf 1.4) contains the following XML snippet in
>> beans.xml:
>>
>> <osgix:managed-service-factory id="test-container"
>> factory-pid="se.digia.connect.routes.test.container"
>>    update-strategy="bean-managed" update-method="configurationUpdate">
>>    <osgix:interfaces>
>>      <value>se.digia.connect.core.api.IService</value>
>>    </osgix:interfaces>
>>    <bean
>> class="se.digia.connect.routes.test.container.impl.TestContainer"/>
>>  </osgix:managed-service-factory>
>>
>> I then drop a configuration file called
>> "se.digia.connect.routes.test.container-first.cfg" in the etc folder. This
>> causes a service containing the correct configuration to be started and
>> registered. Via Felix WebConsole I can see the configuration and it's the
>> correct one. When I delete the configuration file from the "etc" folder,
>> the
>> service is stopped. It all works.
>>
>> However, my bean (an instance
>> of se.digia.connect.routes.test.container.impl.TestContainer) never gets a
>> callback. I expected the "configurationUpdate()" method of the
>> TestContainer
>> class to be called whenever the configuration changes. My callback method
>> has the following signature:
>>
>>  public void configurationUpdate(Map<String, ?> theProperties) throws
>> Exception
>>
>> When I use a "managed-properties" instead of "managed-service-factory" I
>> do
>> get the callback. The following works perfectly:
>>
>>  <bean id="testRoute" class="se.digia.connect.routes.test.impl.TestRoute">
>>    <osgix:managed-properties persistent-id="se.digia.connect.routes.test"
>> update-strategy="bean-managed"
>>      update-method="configurationUpdate" />
>>  </bean>
>>
>>  <spring-osgi:service ref="testRoute"
>> interface="se.digia.connect.core.api.IService"/>
>>
>> What am I missing? How can I get a notification callback when the
>> configuration is changed when using a managed-service-factory?
>>
>> Happy for any clues you may have.
>>
>> By the way is this the recommended way to use managed service factories?
>> Are
>> there any other (non Spring-DM) ways of doing this? IPojo for example.
>>
>> /Bengt
>>
>
>

Re: managed-service-factory but no callback on configuration changes

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

I think you may ask this question in Spring-DM, or Karaf mailing list.
As the question is out of scope of Camel :)

Willem

Bengt Rodehav wrote:
> Hello everyone,
> 
> I'm trying to use Spring-DM's support for managed-service-factory. My
> artifact (deployed in Karaf 1.4) contains the following XML snippet in
> beans.xml:
> 
> <osgix:managed-service-factory id="test-container"
> factory-pid="se.digia.connect.routes.test.container"
>     update-strategy="bean-managed" update-method="configurationUpdate">
>     <osgix:interfaces>
>       <value>se.digia.connect.core.api.IService</value>
>     </osgix:interfaces>
>     <bean
> class="se.digia.connect.routes.test.container.impl.TestContainer"/>
>   </osgix:managed-service-factory>
> 
> I then drop a configuration file called
> "se.digia.connect.routes.test.container-first.cfg" in the etc folder. This
> causes a service containing the correct configuration to be started and
> registered. Via Felix WebConsole I can see the configuration and it's the
> correct one. When I delete the configuration file from the "etc" folder, the
> service is stopped. It all works.
> 
> However, my bean (an instance
> of se.digia.connect.routes.test.container.impl.TestContainer) never gets a
> callback. I expected the "configurationUpdate()" method of the TestContainer
> class to be called whenever the configuration changes. My callback method
> has the following signature:
> 
>   public void configurationUpdate(Map<String, ?> theProperties) throws
> Exception
> 
> When I use a "managed-properties" instead of "managed-service-factory" I do
> get the callback. The following works perfectly:
> 
>   <bean id="testRoute" class="se.digia.connect.routes.test.impl.TestRoute">
>     <osgix:managed-properties persistent-id="se.digia.connect.routes.test"
> update-strategy="bean-managed"
>       update-method="configurationUpdate" />
>   </bean>
> 
>   <spring-osgi:service ref="testRoute"
> interface="se.digia.connect.core.api.IService"/>
> 
> What am I missing? How can I get a notification callback when the
> configuration is changed when using a managed-service-factory?
> 
> Happy for any clues you may have.
> 
> By the way is this the recommended way to use managed service factories? Are
> there any other (non Spring-DM) ways of doing this? IPojo for example.
> 
> /Bengt
> 


Re: managed-service-factory but no callback on configuration changes

Posted by Bengt Rodehav <be...@rodehav.com>.
Sorry, posted to the wrong forum...

/Bengt

2010/3/15 Bengt Rodehav <be...@rodehav.com>

> Hello everyone,
>
> I'm trying to use Spring-DM's support for managed-service-factory. My
> artifact (deployed in Karaf 1.4) contains the following XML snippet in
> beans.xml:
>
> <osgix:managed-service-factory id="test-container"
> factory-pid="se.digia.connect.routes.test.container"
>     update-strategy="bean-managed" update-method="configurationUpdate">
>     <osgix:interfaces>
>       <value>se.digia.connect.core.api.IService</value>
>     </osgix:interfaces>
>     <bean
> class="se.digia.connect.routes.test.container.impl.TestContainer"/>
>   </osgix:managed-service-factory>
>
> I then drop a configuration file called
> "se.digia.connect.routes.test.container-first.cfg" in the etc folder. This
> causes a service containing the correct configuration to be started and
> registered. Via Felix WebConsole I can see the configuration and it's the
> correct one. When I delete the configuration file from the "etc" folder, the
> service is stopped. It all works.
>
> However, my bean (an instance
> of se.digia.connect.routes.test.container.impl.TestContainer) never gets a
> callback. I expected the "configurationUpdate()" method of the TestContainer
> class to be called whenever the configuration changes. My callback method
> has the following signature:
>
>   public void configurationUpdate(Map<String, ?> theProperties) throws
> Exception
>
> When I use a "managed-properties" instead of "managed-service-factory" I do
> get the callback. The following works perfectly:
>
>   <bean id="testRoute" class="se.digia.connect.routes.test.impl.TestRoute">
>     <osgix:managed-properties persistent-id="se.digia.connect.routes.test"
> update-strategy="bean-managed"
>       update-method="configurationUpdate" />
>   </bean>
>
>   <spring-osgi:service ref="testRoute"
> interface="se.digia.connect.core.api.IService"/>
>
> What am I missing? How can I get a notification callback when the
> configuration is changed when using a managed-service-factory?
>
> Happy for any clues you may have.
>
> By the way is this the recommended way to use managed service factories?
> Are there any other (non Spring-DM) ways of doing this? IPojo for example.
>
> /Bengt
>