[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] Working with ConfigAdmin service


I think the problem you're having is one of ordering.  If your bundle starts before the ConfigurationAdmin service is registered then you're not going to find it. This is not a problem and is part of how OSGi works. There are a number of solutions:

1. Use Declarative Services (DS). This is by far the easiest approach since it removes the ordering problem entirely. I strongly recommend that you use DS.

2. Use the ServiceTracker to track the ConfigurationAdmin service.  This works in theory, but in practice is way harder to get right than you might imagine.

3. Register a ServiceListener to track the ConfigurationAdmin service. This also works in theory, but in practice is more work that you'd care to do.  It's debatable whether this is easier or harder than using the ServiceTracker.

See the attached zip that shows how to use DS to acquire a ConfigurationAdmin service.

I hope this helps,


From: Ali Naddaf <ali@xxxxxxxxxx>
To: Equinox development mailing list <equinox-dev@xxxxxxxxxxx>
Date: 09/28/2009 07:41 PM
Subject: [equinox-dev] Working with ConfigAdmin service
Sent by: equinox-dev-bounces@xxxxxxxxxxx

Hello everyone.

I am trying to write a few simple examples with ConfigurationAdmin
service to familiarize myself with it but have a difficulty obtaining a
pointer to the service. I am running Equinox 3.5 and have deployed
org.eclipse.equinox.cm_1.0.100 bundle in my framework but still when I
try to get a reference to the ConfiguartionAdmin (via
context.getServiceReference(ConfigurationAdmin.class.getName()) ), I get
a null pointer. Do I need to set any particular security settings?

Many thanks,
equinox-dev mailing list

Attachment: cm.user.ds.zip
Description: Zip archive