AEM OSGI Configuration

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

转载于:https://my.oschina.net/slightScenery/blog/1863676

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值