Hi

On the first glance a ServiceTracker might achieve what you want.

Best regards
Stephan

-----Original Message-----
From: Ephemeris Lappis <ephemeris.lap...@gmail.com>
Sent: Thursday, 30 November 2023 09:19
To: user@karaf.apache.org
Subject: OSGi managed service factory / Events on changes ?

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.

Reply via email to