Search code examples
osgiaem

How to sync the updates made to osgi config to CRXDE as well?


I can see the updates reflected in the configMgr,enter image description here

crx-quickstart\launchpad\config,enter image description here

and also in the logsenter image description here

but crxde still has the old value enter image description here Am I missing something?

What I have tried, ConfigurationServiceImpl.java:

package org.bundle.services.impl;
@Service({ConfigurationServiceImpl.class})
@Component(immediate=true, metatype=true)
public class ConfigurationServiceImpl
{
@Reference
private ConfigurationAdmin configAdmin;
private static final String 
CONFIG_PID="org.bundle.services.impl.ConfigurationServiceImpl";
private static final Log _logger = LogFactory.getLog(ConfigurationServiceImpl.class);
public static final String LOG_LEVEL = "logLevel";

@Activate
protected void activate(Map<String, Object> properties) throws IOException
{
    _logger.info("[*** AEM ConfigurationService]: activating configuration service");
    initializeConfig(properties);
    readProperties(properties);
}

private void initializeConfig(Map<String, Object> properties) throws IOException {

    Configuration configNode = configAdmin.getConfiguration(CONFIG_PID);

    if (configNode != null && configNode.getProperties() != null) {

        @SuppressWarnings("unchecked")
        Dictionary<String, Object> config = configNode.getProperties();     

        if (config.get(LOG_LEVEL) != null) {
            config.put(LOG_LEVEL, "debug");
        }

        configNode.update(config);
    }
}

protected void readProperties(Map<String, Object> properties) throws IOException
{
    _logger.info(properties.toString());
    Configuration pdConfig = configAdmin.getConfiguration(CONFIG_PID);
    @SuppressWarnings("unchecked")
    Dictionary<String, Object> configProps = config.getProperties();
    String  logLevel = (String) configProps.get("logLevel");
    _logger.info("LOG LEVEL: " + logLevel);
}
}

Solution

  • The changes made via configuration console get written back to the repository and is generally saved under "/apps/system/config". This can change if the configuration was already bound to a different config file. Read https://helpx.adobe.com/experience-manager/6-3/sites/deploying/using/configuring-osgi.html#ConfigurationPersistence.

    The changes you made are definitely saved, it is about locating where the config file was created. Searching with the PID in crxde search box usually helps.

    On a side note, the usage of "initializeConfig" in the sample looks strange, there is no need to use Config Admin to get the configuration properties when the service will always get the latest configs via Activate method.