What is the use of cardinality attribute in @property
annotation in apache felix scr?

- 1,130
- 1
- 12
- 25

- 61
- 1
- 5
1 Answers
It is well explained in Apache Docs here, what is that you are not clear about?
cardinality Defaut: Depends on property value(s) SCR Descriptor: -- Metatype Descriptor: AD.cardinality
Defines the cardinality of the property and its collection type. If the cardinality is negative, the property is expected to be stored in a java.util.Vector (primitive types such as boolean are boxed in the Wrapper class), if the cardinality is positive, the property is stored in an array (primitve types are unboxed, that is Boolean type values are stored in boolean[]()). The actual value defines the maximum number of elements in the vector or array, where Integer.MININT describes an unbounded Vector and Integer.MAXINT describes an unbounded array. If the cardinality is zero, the property is a scalar value. If the defined value of the property is set in the value attribute, the cardinality defaults to 0 (zero for scalar value). If the property is defined in one or more properties starting with values, the cardinality defaults to Integer.MAX_INT, that is an unbounded array.
It refers to what type of property are you storing and if it has single (SCALAR) value or multiple value (UNBOUNDED), read more in scr-javadoc-tags

- 1,652
- 2
- 12
- 18