I have the following service:
@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
........
}
I want MULTI_PROPERTY
to be as array value, to have possibility to use a set of values like on image:
How to implement it?
Use the unbounded
attribute to specify multivalued property and use the cardinality
attribute to restrict the number of entries.
@Property(unbounded = PropertyUnbounded.ARRAY, cardinality=10, label = "Some Label")
private static final String MULTI_PROPERTY = "config.multiproperty";
In order to read the property array you can use #toStringArray()
method of the PropertiesUtil
PropertiesUtil.toStringArray(properties.get(MULTI_PROPERTY));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With