Hi Ephemeris-

OSGi has several hooks you can use. Look into OSGi's EventHandler and 
ServiceTracker

Additionally, you can make another service that takes this service in as a 
reference, then you get called when the service is added and removed.

Look into OSGi component services, and bind/unbind hooks for references.

Thanks,
Matt Pavlovich

> On Nov 30, 2023, at 2:19 AM, Ephemeris Lappis <ephemeris.lap...@gmail.com> 
> 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.

Reply via email to