I have the following case in ops4j pax-jdbc-config
https://github.com/ops4j/org.ops4j.pax.jdbc/tree/master/pax-jdbc-config

I have a ManagesServiceFactory that watches for configs (representing desired datasources) being created and destroyed. For each config I select a DataSourceFactory service by properties specified in the config. I then create DataSource and publish it as a service.
When the config disappears I have to remove the service again.

The difficult thing here is that at the moment when the "updated" for the config comes in there may not yet be a suitable DataSourceFactory service. In my first prototype I then just do not create the DataSource. The problem with this is of course that at startup it is very probable that the configs come in before the DataSourceFactories are up. So my current approach leads to the problem that the DataSources are not created at all in some cases.

So are there any best practices or patterns how to handle this? I think it is a bit similar to blueprint that needs to wait for namespace handlers. I am not sure though if the timeout approach blueprint uses is a good way to approach this. On the other hand you have to report back to the user that his config might be wrong at some point.

Christian

--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to