org.apache.felix.scr.annotations
Annotation Type Property


@Target(value={TYPE,FIELD})
@Retention(value=SOURCE)
@Documented
public @interface Property

The Property annotation defines properties which are made available to the component through the ComponentContext.getProperties() method. These annotations are not strictly required but may be used by components to defined initial configuration. Additionally properties may be set here to identify the component if it is registered as a service, for example the service.description and service.vendor properties.

This tag is used to declare <property> elements of the component declaration. See section 112.4.5, Properties and Property Elements, in the OSGi Service Platform Service Compendium Specification for more information.


Optional Element Summary
 boolean[] boolValue
          The bool value(s) of the property.
 byte[] byteValue
          The byte value(s) of the property.
 int cardinality
          Defines the cardinality of the property and its collection type.
 char[] charValue
          The char value(s) of the property.
 String description
          A descriptive text to provide the client in a form to configure this property.
 double[] doubleValue
          The double value(s) of the property.
 float[] floatValue
          The float value(s) of the property.
 int[] intValue
          The int value(s) of the property.
 String label
          The label to display in a form to configure this property.
 long[] longValue
          The long value(s) of the property.
 String name
          The name of the property
 PropertyOption[] options
          Some properties may only be set to a set of possible values.
 boolean propertyPrivate
          Boolean flag defining whether a metatype descriptor entry should be generated for this property or not.
 short[] shortValue
          The short value(s) of the property.
 PropertyUnbounded unbounded
          This defines if the property is unbounded.
 String[] value
          The value(s) of the property.
 

name

public abstract String name
The name of the property

Default:
""

label

public abstract String label
The label to display in a form to configure this property. This name may be localized by prepending a % sign to the name. Default value: %<name>.name

Default:
""

description

public abstract String description
A descriptive text to provide the client in a form to configure this property. This name may be localized by prepending a % sign to the name. Default value: %<name>.description

Default:
""

value

public abstract String[] value
The value(s) of the property. If the property type is not String, parsing of the value is done using the valueOf(String) method of the class defined by the property type. This attribute should not be used in combination with any of the other value attributes.

Default:
{}

longValue

public abstract long[] longValue
The long value(s) of the property. This attribute should not be used in combination with any of the other value attributes or the type attribute.

Default:
{}

doubleValue

public abstract double[] doubleValue
The double value(s) of the property. This attribute should not be used in combination with any of the other value attributes.

Default:
{}

floatValue

public abstract float[] floatValue
The float value(s) of the property. This attribute should not be used in combination with any of the other value attributes or the type attribute.

Default:
{}

intValue

public abstract int[] intValue
The int value(s) of the property. This attribute should not be used in combination with any of the other value attributes or the type attribute.

Default:
{}

byteValue

public abstract byte[] byteValue
The byte value(s) of the property. This attribute should not be used in combination with any of the other value attributes or the type attribute.

Default:
{}

charValue

public abstract char[] charValue
The char value(s) of the property. This attribute should not be used in combination with any of the other value attributes or the type attribute.

Default:
{}

boolValue

public abstract boolean[] boolValue
The bool value(s) of the property. This attribute should not be used in combination with any of the other value attributes or the type attribute.

Default:
{}

shortValue

public abstract short[] shortValue
The short value(s) of the property. This attribute should not be used in combination with any of the other value attributes or the type attribute.

Default:
{}

cardinality

public abstract int 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 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. 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 an unbounded array.

Default:
0

unbounded

public abstract PropertyUnbounded unbounded
This defines if the property is unbounded. The property can either be an unbounded array or vector. If this attribute is set to any other value than PropertyUnbounded.DEFAULT, this overrides the cardinality().

Since:
1.4
Default:
org.apache.felix.scr.annotations.PropertyUnbounded.DEFAULT

propertyPrivate

public abstract boolean propertyPrivate
Boolean flag defining whether a metatype descriptor entry should be generated for this property or not. By default a metatype descriptor entry, i.e. an AD element, is generated. If a property should not be available for display in a configuration user interface, this parameter should be set to true. For properties names service.ranking the AD element is not created by default, which can be overwritten by stating propertyPrivate=false. For the predefined properties service.pid, service.description, service.id, service.vendor, service.bundlelocation and service.factoryPid an AD element will never be created and the propertyPrivate attribute has no effect.

Default:
false

options

public abstract PropertyOption[] options
Some properties may only be set to a set of possible values. To support user interfaces which provide a selection list of values or a list of checkboxes the option values and labels may be defined as parameters to the Property annotation. All parameters in the form of name-value pairs are used to build the list of available value options. The parameter name is used as the value while the parameter value is used as the label in the user interface. This label may be prepended with a % sign to localize the string.

The options are written to the metatype.xml file as Option elements inside the AD element defining the property. The name of the parameter will be used for the Option.value attribute while the value of the parameter defines the Option.label attribute.

Default:
{}


Copyright © 2011 Apache Software Foundation. All Rights Reserved.