Stuart McCulloch | 26e7a5a | 2011-10-17 10:31:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) OSGi Alliance (2011). All Rights Reserved. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.osgi.service.component.annotations; |
| 18 | |
| 19 | import java.lang.annotation.ElementType; |
| 20 | import java.lang.annotation.Retention; |
| 21 | import java.lang.annotation.RetentionPolicy; |
| 22 | import java.lang.annotation.Target; |
| 23 | |
| 24 | /** |
| 25 | * Identify the annotated class as a Service Component. |
| 26 | * |
| 27 | * <p> |
| 28 | * The annotated class is the implementation class of the Component. |
| 29 | * |
| 30 | * <p> |
| 31 | * This annotation is not processed at runtime by a Service Component Runtime |
| 32 | * implementation. It must be processed by tools and used to add a Component |
| 33 | * Description to the bundle. |
| 34 | * |
| 35 | * @see "The component element of a Component Description." |
| 36 | * @version $Id$ |
| 37 | */ |
| 38 | @Retention(RetentionPolicy.CLASS) |
| 39 | @Target(ElementType.TYPE) |
| 40 | public @interface Component { |
| 41 | /** |
| 42 | * The name of this Component. |
| 43 | * |
| 44 | * <p> |
| 45 | * If not specified, the name of this Component is the fully qualified type |
| 46 | * name of the class being annotated. |
| 47 | * |
| 48 | * @see "The name attribute of the component element of a Component Description." |
| 49 | */ |
| 50 | String name() default ""; |
| 51 | |
| 52 | /** |
| 53 | * The types under which to register this Component as a service. |
| 54 | * |
| 55 | * <p> |
| 56 | * If no service should be registered, the empty value |
| 57 | * <code>{}</code> must be specified. |
| 58 | * |
| 59 | * <p> |
| 60 | * If not specified, the service types for this Component are all the |
| 61 | * <i>directly</i> implemented interfaces of the class being annotated. |
| 62 | * |
| 63 | * @see "The service element of a Component Description." |
| 64 | */ |
| 65 | Class< ? >[] service() default {}; |
| 66 | |
| 67 | /** |
| 68 | * The factory identifier of this Component. Specifying a factory identifier |
| 69 | * makes this Component a Factory Component. |
| 70 | * |
| 71 | * <p> |
| 72 | * If not specified, the default is that this Component is not a Factory |
| 73 | * Component. |
| 74 | * |
| 75 | * @see "The factory attribute of the component element of a Component Description." |
| 76 | */ |
| 77 | String factory() default ""; |
| 78 | |
| 79 | /** |
| 80 | * Declares whether this Component uses the OSGi ServiceFactory concept and |
| 81 | * each bundle using this Component's service will receive a different |
| 82 | * component instance. |
| 83 | * |
| 84 | * <p> |
| 85 | * If {@code true}, this Component uses the OSGi ServiceFactory concept. If |
| 86 | * {@code false} or not specified, this Component does not use the OSGi |
| 87 | * ServiceFactory concept. |
| 88 | * |
| 89 | * @see "The servicefactory attribute of the service element of a Component Description." |
| 90 | */ |
| 91 | boolean servicefactory() default false; |
| 92 | |
| 93 | /** |
| 94 | * Declares whether this Component is enabled when the bundle containing it |
| 95 | * is started. |
| 96 | * |
| 97 | * <p> |
| 98 | * If {@code true}, this Component is enabled. If {@code false} or not |
| 99 | * specified, this Component is disabled. |
| 100 | * |
| 101 | * @see "The enabled attribute of the component element of a Component Description." |
| 102 | */ |
| 103 | boolean enabled() default true; |
| 104 | |
| 105 | /** |
| 106 | * Declares whether this Component must be immediately activated upon |
| 107 | * becoming satisfied or whether activation should be delayed. |
| 108 | * |
| 109 | * <p> |
| 110 | * If {@code true}, this Component must be immediately activated upon |
| 111 | * becoming satisfied. If {@code false}, activation of this Component is |
| 112 | * delayed. If this property is specified, its value must be {@code false} |
| 113 | * if the {@link #factory} property is also specified or must be |
| 114 | * {@code true} if the {@link #service} property is specified with an empty |
| 115 | * value. |
| 116 | * |
| 117 | * <p> |
| 118 | * If not specified, the default is {@code false} if the {@link #factory} |
| 119 | * property is specified or the {@link #service} property is not specified |
| 120 | * or specified with a non-empty value and {@code true} otherwise. |
| 121 | * |
| 122 | * @see "The immediate attribute of the component element of a Component Description." |
| 123 | */ |
| 124 | boolean immediate() default false; |
| 125 | |
| 126 | /** |
| 127 | * The configuration policy of this Component. |
| 128 | * |
| 129 | * <p> |
| 130 | * Controls whether component configurations must be satisfied depending on |
| 131 | * the presence of a corresponding Configuration object in the OSGi |
| 132 | * Configuration Admin service. A corresponding configuration is a |
| 133 | * Configuration object where the PID equals the name of the component. |
| 134 | * |
| 135 | * <p> |
| 136 | * If not specified, the {@link ConfigurationPolicy#OPTIONAL OPTIONAL} |
| 137 | * configuration policy is used. |
| 138 | * |
| 139 | * @see "The configuration-policy attribute of the component element of a Component Description." |
| 140 | */ |
| 141 | ConfigurationPolicy configurationPolicy() default ConfigurationPolicy.OPTIONAL; |
| 142 | |
| 143 | /** |
| 144 | * Properties for this Component. |
| 145 | * |
| 146 | * <p> |
| 147 | * Each property string is specified as {@code "key=value"}. The type of the |
| 148 | * property value can be specified in the key as {@code key:type=value}. The |
| 149 | * type must be one of the property types supported by the type attribute of |
| 150 | * the property element of a Component Description. |
| 151 | * |
| 152 | * <p> |
| 153 | * To specify a property with multiple values, use multiple key, value |
| 154 | * pairs. For example, {@code "foo=bar", "foo=baz"}. |
| 155 | * |
| 156 | * @see "The property element of a Component Description." |
| 157 | */ |
| 158 | String[] property() default {}; |
| 159 | |
| 160 | /** |
| 161 | * Property entries for this Component. |
| 162 | * |
| 163 | * <p> |
| 164 | * Specifies the name of an entry in the bundle whose contents conform to a |
| 165 | * standard Java Properties File. The entry is read and processed to obtain |
| 166 | * the properties and their values. |
| 167 | * |
| 168 | * @see "The properties element of a Component Description." |
| 169 | */ |
| 170 | String[] properties() default {}; |
| 171 | } |