Normal Text:
@Property(label = "Username", value = "*",
description = "username for access the service.")
public static final String USERNAME = "username";
@Property(label = "Password", value = "*",
description = "password for access the service.")
public static final String PASSWORD = "password";
CheckBox:
@Property(boolValue = true,name = "notify",label="Default value for notifyStudyOpen")
Drop Down List:
@Property(label = "Author Gender", description = "Describe Author Gender",
options = { @PropertyOption(name = "Male", value = "1. Male"), @PropertyOption(name = "Female", value = "2. Female") }, value = "Female")
private static final String AUTHOR_GENDER = "author.gender";
Multi Field:
@Property(value={"English", "Hindi"}, unbounded = PropertyUnbounded.ARRAY, label = "Subjects", cardinality = 50, description = "Example for Multi field config") private static final String MULTI_FIELD = "multifield";
字段的初始化
protected void activate(ComponentContext componentContext) {
configure(componentContext.getProperties());
}
public void modified(ComponentContext componentContext) {
configure(componentContext.getProperties());
}
protected void configure(Dictionary<?, ?> properties) {
if(properties.get(Study_Connect_Scheduler) != null){
this.scheduler = (String.valueOf(properties.get(Study_Connect_Scheduler)));
}
}
OR
this.notifyLaySummaryFlag = (Boolean) componentContext.getProperties().get("notifyLaySummary"); name
this.responseType = (String) componentContext.getProperties().get("response.type");
this.multiString = PropertiesUtil.toStringArray( context.getProperties().get(MULTI_FIELD));
可参考:http://www.aemcq5tutorials.com/tutorials/custom-osgi-configuration-aem/
Configuration in the run modes:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
filter.methods="[PUT,DELETE]"/>
In AEM 6.4 or above there has some updates:
@Designate(ocd=SimpleScheduledTask.Config.class)-->For the class\
//In the class for the field
@ObjectClassDefinition(name="A scheduled task",
description = "Simple demo for cron-job like task with properties")
public static @interface Config {
@AttributeDefinition(name = "Cron-job expression")
String scheduler_expression() default "*/30 * * * * ?";
@AttributeDefinition(name = "Concurrent task",
description = "Whether or not to schedule this task concurrently")
boolean scheduler_concurrent() default false;
@AttributeDefinition(name = "A parameter",
description = "Can be configured in /system/console/configMgr")
String myParameter() default "";
}
private String myParameter;
//init function while the service is active
@Activate
protected void activate(final Config config) {
myParameter = config.myParameter();
}
@AttributeDefinition(name = "Jobs Import Process Type",
description = "The type of job import process", options = {
@Option(label = "Automatic", value = "automatic"),
@Option(label = "Manual", value = "manual")}
)
String process_type() default "automatic";
AEM6.4
https://helpx.adobe.com/experience-manager/using/osgi_config63.html