blob: 4b90e6bb280faadb845e51fd47055de7f03c725b [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 */
19package org.apache.felix.scrplugin.annotations;
20
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 */
35@Target(ElementType.TYPE)
Carsten Ziegelerb5618fe2009-03-31 17:18:17 +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 */
43 String name();
44
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.
63 */
64 String[] value();
65
66 /**
67 * The type of the property value. This must be one of {@link String},
68 * {@link Long}, {@link Double}, {@link Float}, {@link Integer},
69 * {@link Byte}, {@link Character}, {@link Boolean} and {@link Short}.
70 */
71 Class type() default AutoDetect.class;
72
73 /**
74 * Defines the cardinality of the property and its collection type. If the
75 * cardinality is negative, the property is expected to be stored in a
76 * {@link java.util.Vector} (primitive types such as boolean are boxed in
77 * the Wrapper class), if the cardinality is positive, the property is
78 * stored in an array (primitve types are unboxed, that is Boolean type
79 * values are stored in boolean[]). The actual value defines the maximum
80 * number of elements in the vector or array, where Integer.MIN_INT
81 * describes an unbounded Vector and Integer.MAX_INT describes an unbounded
82 * array. If the cardinality is zero, the property is a scalar value. If the
83 * defined value of the property is set in the value attribute, the
84 * cardinality defaults to 0 (zero for scalar value). If the property is
85 * defined in one or more properties starting with values, the cardinality
86 * defaults to Integer.MAX_INT, that is an unbounded array.
87 */
88 int cardinality() default 0;
89
90 /**
91 * Boolean flag defining whether a metatype descriptor entry should be
92 * generated for this property or not. By default a metatype descriptor
93 * entry, i.e. an AD element, is generated except for the properties
94 * <code>service.pid</code>, <code>service.description</code>,
95 * <code>service.id</code>, <code>service.ranking</code>,
96 * <code>service.vendor</code>, <code>service.bundlelocation</code> and
97 * <code>service.factoryPid</code>. If a property should not be available
98 * for display in a configuration user interface, this parameter should be
99 * set to true.
100 */
101 boolean propertyPrivate() default false;
102
103 /**
104 * Some properties may only be set to a set of possible values. To support
105 * user interfaces which provide a selection list of values or a list of
106 * checkboxes the option values and labels may be defined as parameters to
107 * the {@link Property} annotation. All parameters in the form of name-value
108 * pairs are used to build the list of available value options. The
109 * parameter name is used as the value while the parameter value is used as
110 * the label in the user interface. This label may be prepended with a %
111 * sign to localize the string.
112 * <p>
113 * The options are written to the metatype.xml file as Option elements
114 * inside the AD element defining the property. The name of the parameter
115 * will be used for the Option.value attribute while the value of the
116 * parameter defines the Option.label attribute.
117 */
118 PropertyOption[] options() default {};
119
120}