blob: 348a73a8b48e5a51e33c7f0505cc76f14f1f35f5 [file] [log] [blame]
Carsten Ziegeler5de92da2009-03-31 17:12:40 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
Carsten Ziegelerba751bd2009-04-18 18:31:43 +000019package org.apache.felix.scr.annotations;
Carsten Ziegeler5de92da2009-03-31 17:12:40 +000020
Carsten Ziegelerb5618fe2009-03-31 17:18:17 +000021import java.lang.annotation.*;
Carsten Ziegeler5de92da2009-03-31 17:12:40 +000022
23/**
24 * The <code>Property</code> annotation defines properties which are made
25 * available to the component through the ComponentContext.getProperties()
26 * method. These annotations are not strictly required but may be used by
27 * components to defined initial configuration. Additionally properties may be
28 * set here to identify the component if it is registered as a service, for
29 * example the service.description and service.vendor properties.
30 * <p>
31 * This tag is used to declare &lt;property&gt; elements of the component
32 * declaration. See section 112.4.5, Properties and Property Elements, in the
33 * OSGi Service Platform Service Compendium Specification for more information.
34 */
Carsten Ziegeler27764de2009-04-16 09:39:33 +000035@Target( { ElementType.TYPE, ElementType.FIELD })
Carsten Ziegeler1993d102009-04-07 16:16:47 +000036@Retention(RetentionPolicy.SOURCE)
Carsten Ziegeler5de92da2009-03-31 17:12:40 +000037@Documented
38public @interface Property {
39
40 /**
41 * The name of the property
42 */
Carsten Ziegelera4ca8fe2009-04-23 05:52:04 +000043 String name() default "";
Carsten Ziegeler5de92da2009-03-31 17:12:40 +000044
45 /**
46 * The label to display in a form to configure this property. This name may
47 * be localized by prepending a % sign to the name. Default value:
48 * %&lt;name&gt;.name
49 */
50 String label() default "";
51
52 /**
53 * A descriptive text to provide the client in a form to configure this
54 * property. This name may be localized by prepending a % sign to the name.
55 * Default value: %&lt;name&gt;.description
56 */
57 String description() default "";
58
59 /**
60 * The value(s) of the property. If the property type is not String, parsing
61 * of the value is done using the valueOf(String) method of the class
62 * defined by the property type.
Carsten Ziegeler9aa4f3b2009-05-14 20:05:45 +000063 * This attribute should not be used in combination with any of the other
64 * value attributes.
Carsten Ziegeler5de92da2009-03-31 17:12:40 +000065 */
Carsten Ziegeler5d33aaf2009-05-19 06:24:41 +000066 String[] value() default {};
Carsten Ziegeler5de92da2009-03-31 17:12:40 +000067
68 /**
Carsten Ziegeler9aa4f3b2009-05-14 20:05:45 +000069 * The long value(s) of the property.
70 * This attribute should not be used in combination with any of the other
71 * value attributes or the type attribute.
Carsten Ziegeler5de92da2009-03-31 17:12:40 +000072 */
Carsten Ziegeler5d33aaf2009-05-19 06:24:41 +000073 long[] longValue() default {};
Carsten Ziegeler9aa4f3b2009-05-14 20:05:45 +000074
75 /**
76 * The double value(s) of the property.
77 * This attribute should not be used in combination with any of the other
78 * value attributes.
79 */
Carsten Ziegeler5d33aaf2009-05-19 06:24:41 +000080 double[] doubleValue() default {};
Carsten Ziegeler9aa4f3b2009-05-14 20:05:45 +000081
82 /**
83 * The float value(s) of the property.
84 * This attribute should not be used in combination with any of the other
85 * value attributes or the type attribute.
86 */
Carsten Ziegeler5d33aaf2009-05-19 06:24:41 +000087 float[] floatValue() default {};
Carsten Ziegeler9aa4f3b2009-05-14 20:05:45 +000088
89 /**
90 * The int value(s) of the property.
91 * This attribute should not be used in combination with any of the other
92 * value attributes or the type attribute.
93 */
Carsten Ziegeler5d33aaf2009-05-19 06:24:41 +000094 int[] intValue() default {};
Carsten Ziegeler9aa4f3b2009-05-14 20:05:45 +000095
96 /**
97 * The byte value(s) of the property.
98 * This attribute should not be used in combination with any of the other
99 * value attributes or the type attribute.
100 */
Carsten Ziegeler5d33aaf2009-05-19 06:24:41 +0000101 byte[] byteValue() default {};
Carsten Ziegeler9aa4f3b2009-05-14 20:05:45 +0000102
103 /**
104 * The char value(s) of the property.
105 * This attribute should not be used in combination with any of the other
106 * value attributes or the type attribute.
107 */
Carsten Ziegeler5d33aaf2009-05-19 06:24:41 +0000108 char[] charValue() default {};
Carsten Ziegeler9aa4f3b2009-05-14 20:05:45 +0000109
110 /**
111 * The bool value(s) of the property.
112 * This attribute should not be used in combination with any of the other
113 * value attributes or the type attribute.
114 */
Carsten Ziegeler5d33aaf2009-05-19 06:24:41 +0000115 boolean[] boolValue() default {};
Carsten Ziegeler9aa4f3b2009-05-14 20:05:45 +0000116
117 /**
118 * The short value(s) of the property.
119 * This attribute should not be used in combination with any of the other
120 * value attributes or the type attribute.
121 */
Carsten Ziegeler5d33aaf2009-05-19 06:24:41 +0000122 short[] shortValue() default {};
Carsten Ziegeler5de92da2009-03-31 17:12:40 +0000123
124 /**
125 * Defines the cardinality of the property and its collection type. If the
126 * cardinality is negative, the property is expected to be stored in a
127 * {@link java.util.Vector} (primitive types such as boolean are boxed in
128 * the Wrapper class), if the cardinality is positive, the property is
129 * stored in an array (primitve types are unboxed, that is Boolean type
130 * values are stored in boolean[]). The actual value defines the maximum
Carsten Ziegeler341b7872010-07-19 11:32:29 +0000131 * number of elements in the vector or array. If the cardinality is
Felix Meschbergereb4802e2010-01-06 06:30:32 +0000132 * zero, the property is a scalar value. If the defined value of the
Carsten Ziegeler341b7872010-07-19 11:32:29 +0000133 * property is set in the value attribute, the cardinality defaults to 0
Felix Meschbergereb4802e2010-01-06 06:30:32 +0000134 * (zero for scalar value). If the property is defined in one or more
135 * properties starting with values, the cardinality defaults to
Carsten Ziegeler341b7872010-07-19 11:32:29 +0000136 * an unbounded array.
Carsten Ziegeler5de92da2009-03-31 17:12:40 +0000137 */
138 int cardinality() default 0;
139
140 /**
Carsten Ziegeler341b7872010-07-19 11:32:29 +0000141 * This defines if the property is unbounded. The property can either be
142 * an unbounded array or vector. If this attribute is set to any other
143 * value than {@link PropertyUnbounded#DEFAULT},
144 * this overrides the {@link #cardinality()}.
145 * @since 1.4
146 */
147 PropertyUnbounded unbounded() default PropertyUnbounded.DEFAULT;
148
149 /**
Carsten Ziegeler5de92da2009-03-31 17:12:40 +0000150 * Boolean flag defining whether a metatype descriptor entry should be
151 * generated for this property or not. By default a metatype descriptor
152 * entry, i.e. an AD element, is generated except for the properties
153 * <code>service.pid</code>, <code>service.description</code>,
154 * <code>service.id</code>, <code>service.ranking</code>,
155 * <code>service.vendor</code>, <code>service.bundlelocation</code> and
156 * <code>service.factoryPid</code>. If a property should not be available
157 * for display in a configuration user interface, this parameter should be
158 * set to true.
159 */
160 boolean propertyPrivate() default false;
161
162 /**
163 * Some properties may only be set to a set of possible values. To support
164 * user interfaces which provide a selection list of values or a list of
165 * checkboxes the option values and labels may be defined as parameters to
166 * the {@link Property} annotation. All parameters in the form of name-value
167 * pairs are used to build the list of available value options. The
168 * parameter name is used as the value while the parameter value is used as
169 * the label in the user interface. This label may be prepended with a %
170 * sign to localize the string.
171 * <p>
172 * The options are written to the metatype.xml file as Option elements
173 * inside the AD element defining the property. The name of the parameter
174 * will be used for the Option.value attribute while the value of the
175 * parameter defines the Option.label attribute.
176 */
177 PropertyOption[] options() default {};
178
179}