Hi David, Same as Ikuo, I am not sure, I completely understand you here ;-)
David Bosschaert schrieb: > 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? What do you mean by "presence" ? Availability of the cm package for import (i.e. there is an exporter) or existence of the Configuration Admin service (i.e. registered in the Service Registry) ? > 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? Assuming you mean "availabilty of the cm packages for import", I would create a separate class implementing the ManagedService interface. In the client class you create an register the managed service object guarding against and NoClassDefFoundError's thrown while loading the class. So you can define the cm import as optional. Thus you get configuration iff cm can be resolved and a Configuration Admin Service becomes active. But you still are able to operate on defaults without it. Drawback: This is a somewhat static approach in that check cm package availability only takes place once and if cm becomes available after the fact your bundle will not know. HTH Regards Felix _______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
