• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Spring Dm : Export service dynamicaly

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With Spring Dm, it is possible to import and export services at application startup.

On import, it is possible to define a cardinality 0, to make the service optional. What is practical.

But on the export, it exports all configured services at bundle startup.
But is it possible to export services dynamically?

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?
 
author
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic