Hello JB.

I've tried with a ServiceListener that also seems to match my need. The ConfigurationListener seems not to be very different, but a bit more verbose I think. With the service listener I immediately get the "managed" service reference. What do you think about this option ?

Thanks a lot.

Regards.

Ephemeris Lappis

Le 04/12/2023 à 16:02, Jean-Baptiste Onofré a écrit :
Hi,

You can use a ConfigListener, similar to what we do in Cellar Config:

https://github.com/apache/karaf-cellar/blob/main/config/src/main/java/org/apache/karaf/cellar/config/LocalConfigurationListener.java

Regards
JB

On Thu, Nov 30, 2023 at 9:19 AM Ephemeris Lappis
<[email protected]> wrote:
Hello.

To manage some kind of dynamic configuration, I've used a managed
service factory. It works as expected, and I can add, update or remove
instances deploying or undeploying files in the etc folder.

The simple blueprint is like that :

<?xml version="1.0" encoding="UTF-8"?>
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0
http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd";>

<cm:managed-service-factory
factory-pid="com.together.ms"
interface="com.together.MyService">
<cm:managed-component class="com.together.component.MyServiceManagedComponent">
<cm:managed-properties
persistent-id=""
update-strategy="container-managed" />
</cm:managed-component>
</cm:managed-service-factory>
</blueprint>

In another bundle, I'd like to know when an instance has been updated
or removed (new ones don't really matter). What's the best way to do
it, if possible ? Are there some kind of events and listeners to spy
managed services ?

Thanks for your help.

Regards.

--
Cet e-mail a été vérifié par le logiciel antivirus d'Avast.
www.avast.com

Reply via email to