I think your question is: How long do I wait for my ManagedService to be 
called with my configuration before I decide I need to use some defaults?

There are 2 reasons why your MS may not get called. (1) There is no 
ConfigAdmin running (yet). (2) Your MS does not have a configuration.

(1) Can be detected because there is no ConfigAdmin service registered. If 
this is the case, use your defaults but still register the MS because the 
ConfigAdmin service may get started shortly.

(2) If there is a ConfigAdmin service, then you may want some timeout 
before you give up waiting for some configuration and using your defaults. 
In this case still leave your MS registered.

In all cases, register the MS and respond to update.
-- 

BJ Hargrave
Senior Technical Staff Member, IBM
OSGi Fellow and CTO of the OSGi Alliance
[email protected]

office: +1 386 848 1781
mobile: +1 386 848 3788




From:
David Bosschaert <[email protected]>
To:
OSGi Developer Mail List <[email protected]>
Date:
2009/11/12 23:22
Subject:
[osgi-dev] How to reliably detect that Configuration Admin is *not* 
present?
Sent by:
[email protected]



Hi all,

I have a bundle that can be configured through Configuration Admin. 
However when CA is *not* present it can still function using default 
behaviour.

Question 1: What would be the best way to let it check that the 
Configuration Admin service is not present, so that it can proceed with 
its default behaviour?

Question 2: I would really like it to have an *optional* dependency on 
org.osgi.service.cm. but still my code provides a class that implements 
org.osgi.service.cm.ManagedService I guess this should be possible, 
right? I was thinking of the following algorithm:

If Not Config Admin Present then
  default behaviour
else
  register MyManagedService // only at this point the ManagedService 
class gets loaded
  ... handle configuration as soon as updated() gets called.

Is this a feasible approach?

Thanks,

David


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

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

Reply via email to