Hi Gildas
Gildas Cuisinier wrote:With Spring Dm, it is possible to import and export services at application startup.
Yes - this is the default behaviour. Services defined/referenced using <osgi:service> and <osgi:reference>
are defined when the application context is created.
Gildas Cuisinier wrote:
On import, it is possible to define a cardinality 0, to make the service optional. What is practical.
Yes, that's cardinality "0..1"
Gildas Cuisinier wrote:
But on the export, it exports all configured services at bundle startup.
But is it possible to export services dynamically?
Sure, you can use the OsgiServiceFactoryBean directly and create it lazily. There is a registerService property that you
can set to control this behaviour (or at least there was, haven't checked recently)
Gildas Cuisinier wrote:
Use case
If a condition is verified, a service will be exported.
Once this condition changes, the service will be unpublished from the OSGi registry.
Once the condition is verified again, the service will be exported again.
Does SpringDm provided a mechanism for that, or do we necessarily use the OSGi API manually?
At some point it may be easier to use the OSGi API manually, or you can maniulate the bean registry directly
to create/destroy the beans you are interested in.