| Re: [equinox-dev] Working with ConfigAdmin service |
|
Hi Simon. Thanks for you detailed help, very much appreciated. I managed to get around that and now I am running into a different problem when I am trying to update teh configuration in my managed service. I see the following in my log: Warn [4] Configuration for service.pid=test.bundle could not be bound to file:LogTest2_1.0.0.jar initial@reference:file:org.eclipse.equinox.cm_1.0.100.v20090520-1800.jar/ What are the possible causes of this and where should I start looking for the issue? I have a simple Managed Service, LogTest2 bundle: ------- Activator of LogTest2 Bundle ------------------------ (snippet) public void start(BundleContext context) throws Exception { ...... Properties properties = new Properties(); properties.put(Constants.SERVICE_PID, "test.bundle"); registration = context.registerService(ManagedService.class.getName(), this, properties); ....... } public void updated(Dictionary properties) throws ConfigurationException { System.out.println("Configuration is being updated..."); Integer newLogLevel = (Integer) properties.get("log-level"); String newLogLocation = (String) properties.get("log-location"); ........ } --------------------------------------------------------------------------------- And I have a bundle (called LogConfigurator) to update configuration for LogTest2 bundle: -------my main Component for LogConfigurator ------------- public void setConfigAdmin(ConfigurationAdmin admin) { this.admin = admin; } public void unsetConfigAdmin(ConfigurationAdmin admin) { this.admin = null; } public void activate(ComponentContext context) { try { config = admin.getConfiguration("test.bundle"); if (null != config) { Dictionary properties = config.getProperties(); // this prints out the location for LogConfigurator instead of LogTest2! // which I guess it means it hasn't found the LogTest2 bundle System.out.println(config.getBundleLocation()); if (null == properties) { properties = new Properties(); } properties.put("log-level", 3); config.update(properties); System.out.println("Updated configuration to log level 3"); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } -------------------------------------------------------------- The order in which I do these is that first I install and activate Logtest2 and then I install and enable LogConfigurator. The println at the top of the "updated()" method is never called when LogConfigurator is installed, which is consistent with the wrong bundle location that I get in LogConfigurator. Thanks, Ali. P.S. the warning message that I mentioned earlier is when I reverse the order of installations. Simon J Archer wrote:
|