如何在OSGi中使用多值(数组)属性?
我有以下服务:如何在OSGi中使用多值(数组)属性?,osgi,aem,apache-felix,Osgi,Aem,Apache Felix,我有以下服务: @Component( immediate = true, metatype = true) @Service @Property(name = EventConstants.EVENT_TOPIC, value = {ReplicationAction.EVENT_TOPIC}) public class MyService implements EventHandler { @Property private static f
@Component(
immediate = true,
metatype = true)
@Service
@Property(name = EventConstants.EVENT_TOPIC, value = {ReplicationAction.EVENT_TOPIC})
public class MyService implements EventHandler {
@Property
private static final String MULTI_PROPERTY = "config.multiproperty";
........
//another implementation
........
}
我希望MULTI_属性
作为数组值,可以使用一组值,如图像上的值:
如何实现它?使用
无界属性指定多值属性,并使用基数属性限制条目数
@Property(unbounded = PropertyUnbounded.ARRAY, cardinality=10, label = "Some Label")
private static final String MULTI_PROPERTY = "config.multiproperty";
要读取属性数组,可以使用PropertiesUtil
PropertiesUtil.toStringArray(properties.get(MULTI_PROPERTY));