cyl*_*r.y 6 osgi apache-felix aem
我有以下服务:
@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
........
}
Run Code Online (Sandbox Code Playgroud)
我想MULTI_PROPERTY成为数组值,有可能使用像图像上的一组值:
怎么实现呢?
使用该unbounded属性指定多值属性,并使用该cardinality属性限制条目数.
@Property(unbounded = PropertyUnbounded.ARRAY, cardinality=10, label = "Some Label")
private static final String MULTI_PROPERTY = "config.multiproperty";
Run Code Online (Sandbox Code Playgroud)
为了读取属性数组,您可以使用#toStringArray()方法PropertiesUtil
PropertiesUtil.toStringArray(properties.get(MULTI_PROPERTY));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4179 次 |
| 最近记录: |