Hi,

On 25.02.2010 15:49, Ulf Dittmer wrote:
>> Point is, that you are probably doing the wrong thing:
>> The objectClass is an array possibly containing more than one entry. If
>> the ConfigurationAdmin class name is not the first entry it is missed.
> 
> I had actually checked that that was not the case; the code I posted was 
> slightly simplified. Sorry if that was misleading. Would it then be a bug?
> 

Well, without seeing the actual code, I cannot tell more. I just know
that the ConfigurationAdmin service registers itself correctly.

One issue, that can occurr outside of the code is, if the
ConfigurationAdmin bundle is bound to another export of the
org.osgi.service.cm package than your client bundle.

> 
>> If you are interested in the ConfigurationAdmin service, you should
>> explicitly listen for that service and nothing else:
>>
>>    bundleContext.addServiceListener(listener,  "(objectClass=" + 
>> ConfigurationAdmin.class.getName() + ")");
>>
>> Better yet: use the ServiceTracker:
> 
> While I could do either, the app is kind of a generic bundle/service 
> container that acts on ALL installed bundles and services. It obviously does 
> something special for a ConfigAdmin, but other than that I was really hoping 
> to keep it as generic as possible.

Generic is good, but it should not be overdone.

> 
> 
>> Yet, you should not assign the ConfigurationAdmin service to an instance
>> field in this case and instead call the getService() when you need the 
>> service.
> 
> Why is that? (Just trying to understand if there's something about OSGi or 
> Felix that I don't have a handle on yet.)

If you assign it to a field and do not reset the field if the service is
unregistered you cause at least two issues: when calling the defunct
service you get unexpected errors and you keep a reference to the
service preventing the garbage collector from doing its work.

This is really mostly a problem if you are using the ServiceTracker. If
your are using your home-grown solution, you just have to make sure to
drop the reference on service unregistration.

Regards
Felix
> 
> Thanks,
> Ulf
> 
> 
> 
>       
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to