Adobe 如何在CQ5中配置声明性服务

Adobe 如何在CQ5中配置声明性服务,adobe,osgi,aem,apache-felix,Adobe,Osgi,Aem,Apache Felix,如何通过CQ5中的OSGI控制台配置声明性服务。 我能够构建示例服务,将从jar获得并通过捆绑包安装的代码捆绑在一起 OSGI控制台第一步是定义您的服务是否具有配置参数。您可能会有这样的情况: package com.sample.osgi; import java.util.Map; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; imp

如何通过CQ5中的OSGI控制台配置声明性服务。 我能够构建示例服务,将从jar获得并通过捆绑包安装的代码捆绑在一起
OSGI控制台

第一步是定义您的服务是否具有配置参数。您可能会有这样的情况:

package com.sample.osgi;

import java.util.Map;

import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Modified;
import org.apache.felix.scr.annotations.Property;

@Component(label = "Service Label", description = "Service Description", metatype = true, immediate = true)
public class ConfigurableService {

    @Property(value="default value", label = "Sample Parameter", description = "Example of a component parameter")  
    private static final String SAMPLE_PARAM_NAME = "param.one"; 

    @Activate
    protected void activate(final Map<String, Object> props) {
        this.update(props);
    }

    @Modified
    protected void update(final Map<String, Object> props) {        
        System.out.println(props.get(SAMPLE_PARAM_NAME));
    }

}
当我们添加带有@Modified注释的更新方法时,您的组件将在调用该方法时接收对配置值的更新

您可以找到有关SCR注释的更多信息

您可能会觉得有用。
http://localhost:4502/system/console/configMgr/com.sample.osgi.ConfigurableService