如何将对 osgi 配置所做的更新也同步到 CRXDE?

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

我可以在 configMgr 中看到更新,

crx-quickstart\launchpad\config,

也在日志中

但是 crxde 仍然有旧值 我是不是遗漏了什么?

我试过的, 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);
}
}

通过配置控制台所做的更改会写回存储库,通常保存在“/apps/system/config”下。如果配置已经绑定到不同的配置文件,这可能会改变。阅读 https://helpx.adobe.com/experience-manager/6-3/sites/deploying/using/configuring-osgi.html#ConfigurationPersistence.

您所做的更改肯定已保存,这是关于找到创建配置文件的位置。在 crxde 搜索框中使用 PID 进行搜索通常会有所帮助。

附带说明一下,示例中 "initializeConfig" 的用法看起来很奇怪,当服务始终通过 Activate 方法获取最新配置时,无需使用 Config Admin 获取配置属性。

此外,您可以将配置文件添加到您的代码中,并在部署代码时应用它。