@Retention(value=CLASS) @Target(value={TYPE,ANNOTATION_TYPE}) @Repeatable(value=RepeatableProperty.class) public @interface Property
Component.properties()
attribute.Property value(s) type is String by default, and the type is scalar if the value is single-valued, or an array if the value is multi-valued. You can apply this annotation on a component class multiple times (it's a java8 repeatable property). Eight primitive types are supported:
value
and type
attributes,
or using one of the longValue/doubleValue/floatValue/intValue/byteValue/charValue/booleanValue/shortValue
attributes.
Notice that you can also specify service properties dynamically by returning a Map from a method
annotated with Start
.
@Component @Property(name="p1", value="v") // String value type (scalar) @Property(name="p2", value={"s1", "s2"}) // Array of Strings @Property(name="service.ranking", intValue=10) // Integer value type (scalar) @Property(name="p3", intValue={1,2}) // Array of Integers @Property(name="p3", value="1", type=Long.class) // Long value (scalar) class ServiceImpl implements Service { }
Modifier and Type | Required Element and Description |
---|---|
java.lang.String |
name
Returns the property name.
|
Modifier and Type | Optional Element and Description |
---|---|
boolean[] |
booleanValue
A Boolean value or an array of Boolean values.
|
byte[] |
byteValue
A Byte value or an array of Byte values.
|
char[] |
charValue
A Character value or an array of Character values.
|
double[] |
doubleValue
A Double value or an array of Double values.
|
float[] |
floatValue
A Float value or an array of Float values.
|
int[] |
intValue
An Integer value or an array of Integer values.
|
long[] |
longValue
A Long value or an array of Long values.
|
short[] |
shortValue
A Short value or an array of Short values.
|
java.lang.Class<?> |
type
|
java.lang.String[] |
value
Returns the property value(s).
|
java.lang.String[] |
values
Deprecated.
use
value() attribute. |
public abstract java.lang.String name
public abstract java.lang.String[] value
valueOf
method of the class specified in the #type attribute
(which is String
by default). When the property value is single-value, then
the value type is scalar (not an array). If the property value is multi-valued, then the value type
is an array of the type specified in the type()
attribute (String by default).public abstract long[] longValue
public abstract double[] doubleValue
public abstract float[] floatValue
public abstract int[] intValue
public abstract byte[] byteValue
public abstract char[] charValue
public abstract boolean[] booleanValue
public abstract short[] shortValue
public abstract java.lang.String[] values
value()
attribute.valueOf
method of the class specified in the #type attribute
(which is String
by default).