Using the Config admin service [message #1044191] |
Thu, 18 April 2013 15:45 |
Franck Mising name Messages: 92 Registered: July 2009 Location: France |
Member |
|
|
I am wondering how to use the config admin service from my bundles deployed in Virgo, I must be missing something fundamental.
I have my configuration artifact properly listed in the admin console, with the right service.pid;
I register my service from a BundleActivator, and debugging shows that the call happens and uses the right PID.
My ManagedService.updated method however never gets called. The only thing I did config-wise is to declare my service class as implementing ManagedService, and implementing the updated method.
If I understand correctly the Config admin service is supposed to immediately call updated upon registration (even if no config has been set yet), what am I missing?
Is the config admin service running in the user region by default?
Thanks!
Franck
public void start(BundleContext context) throws Exception
{
Dictionary<String, Object> config = new Hashtable<String, Object>();
config.put(Constants.SERVICE_PID, SERVICE_ID);
context.registerService(SERVICE_ID, this, config);
}
public void updated(Dictionary<String, ?> config) throws ConfigurationException
{
...
}
Edit: Answered the last question - the service is up and running according to the user region console:
{org.osgi.service.cm.ConfigurationAdmin}={service.id=59}
"Registered by bundle:" org.eclipse.equinox.cm_1.0.400.v20120319-2029 [15]
"Bundles using service"
org.eclipse.equinox.ds_1.4.0.v20120112-1400 [19]
org.eclipse.gemini.management_1.0.5.RELEASE [26]
org.eclipse.virgo.nano.core_3.6.1.RELEASE [41]
org.eclipse.virgo.medic.core_3.6.1.RELEASE [38]
org.eclipse.virgo.kernel.osgi_3.6.1.RELEASE [33]
org.eclipse.virgo.kernel.services_3.6.1.RELEASE [34]
org.eclipse.virgo.kernel.userregionfactory_3.6.1.RELEASE [35]
org.eclipse.virgo.kernel.model_3.6.1.RELEASE [32]
[Updated on: Thu, 18 April 2013 15:48] Report message to a moderator
|
|
|
|
|
Re: Using the Config admin service [message #1044940 is a reply to message #1044826] |
Fri, 19 April 2013 14:34 |
Franck Mising name Messages: 92 Registered: July 2009 Location: France |
Member |
|
|
Well, there seems to be something fundamental I don't understand about OSGI service registrations.
Looking at one example that works with config admin, org.eclipse.virgo.kernel.userregion.internal.ConsoleConfigurationConvertor, I find this:
this.configuratorRegistration = this.context.registerService(ManagedService.class, new ConsoleConfigurator(), consoleProperties)
I thought the first argument to registerService was the "the class name under which the service can be located" (quoting the javadoc)??
Or... should I understand that I must contribute one service to receive config updates, and one service to implement whatever features I want to provide?
Confused...
Edit: two services seems to be the idea, according to the Log Service description below. Went through at least 20 config admin tutorial page and not a single one explained that clearly... sigh
Everything works fine with a dedicated ManagedService to receive updates in addition to the real service.
http://dz.prosyst.com/pdoc/mBS_SDK/um/runtime/osgi/docs/framework/bundles/osgi/log/log.html#manserv
[Updated on: Fri, 19 April 2013 14:49] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03787 seconds