blob: e67ba5c8a9b629525d85477b1f0af2d869b565f5 [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>Component</code> annotation is the only required annotation. If
25 * this annotation is not declared in a Java class, the class is not declared as
26 * a component.
27 * <p>
28 * This annotation is used to declare the &lt;component&gt; element of the
29 * component declaration. See section 112.4.3, Component Element, in the OSGi
30 * Service Platform Service Compendium Specification for more information. The
31 * required &lt;implementation&gt; element is automatically generated with the
32 * fully qualified name of the class containing the <code>Component</code>
33 * annotation.
34 * </p>
35 */
36@Target(ElementType.TYPE)
Carsten Ziegeler1993d102009-04-07 16:16:47 +000037@Retention(RetentionPolicy.SOURCE)
Carsten Ziegeler5de92da2009-03-31 17:12:40 +000038public @interface Component {
39
40 /**
41 * Defines the Component name also used as the PID for the Configuration
42 * Admin Service. Default value: Fully qualified name of the Java class.
43 */
44 String name() default "";
45
46 /**
47 * This is generally used as a title for the object described by the meta
48 * type. This name may be localized by prepending a % sign to the name.
49 * Default value: %&lt;name&gt;.name
50 */
51 String label() default "";
52
53 /**
54 * This is generally used as a description for the object described by the
55 * meta type. This name may be localized by prepending a % sign to the name.
Carsten Ziegeler27764de2009-04-16 09:39:33 +000056 * Default value: %&lt;name&gt;.description
Carsten Ziegeler5de92da2009-03-31 17:12:40 +000057 */
58 String description() default "";
59
60 /**
61 * Whether the component is enabled when the bundle starts.
62 */
63 boolean enabled() default true;
64
65 /**
66 * Whether the component is a factory component.
67 */
68 String factory() default "";
69
70 /**
71 * Whether the component is immediately activated.
72 */
73 boolean immediate() default false;
74
75 /**
76 * Whether any service, property and reference declarations from base
77 * classes should be inherited by this class.
78 */
79 boolean inherit() default true;
80
81 /**
82 * Whether Metatype Service data is generated or not. If this parameter is
Carsten Ziegelerbe622402009-04-07 15:18:01 +000083 * set to true Metatype Service data is generated in the
Carsten Ziegeler5de92da2009-03-31 17:12:40 +000084 * <code>metatype.xml</code> file for this component. Otherwise no Metatype
85 * Service data is generated for this component.
86 */
Carsten Ziegelerea39fc52009-04-06 19:00:14 +000087 boolean metatype() default false;
Carsten Ziegeler5de92da2009-03-31 17:12:40 +000088
89 /**
90 * This marks an abstract service description which is not added to the
91 * descriptor but intended for reuse through inheritance. This attribute
92 * defaults to true for abstract classes and false for concrete classes.
93 */
94 boolean componentAbstract() default false;
95
96 /**
97 * Whether Declarative Services descriptor is generated or not. If this
98 * parameter is not set or set to true the Declarative Services descriptor
99 * is generated in the service descriptor file for this component. Otherwise
100 * no Declarative Services descriptor is generated for this component.
101 */
102 boolean ds() default true;
103
104 /**
Felix Meschbergerd8e7aac2009-10-06 07:43:57 +0000105 * The version of the Declarative Services specification against which the
106 * component is written. Generally, the Maven SCR Plugin is able to
107 * automatically detect which specification version a Component is written
108 * against. There are some cases, though, where this is not easily or
109 * reliably possible. In these cases use this attribute to force the
110 * specification version.
111 * <p>
112 * Valid values currently are <code>1.0</code> and <code>1.1</code>. If
113 * an unsupported value is declared, a descriptor failure results.
114 *
115 * @since 1.0.1
116 */
117 String specVersion() default "1.0";
118
119 /**
Carsten Ziegeler5de92da2009-03-31 17:12:40 +0000120 * Generated <code>service.pid</code> property by default, if none declared
121 * explicitly.
122 */
123 boolean createPid() default true;
124
Carsten Ziegeler6e0c9332009-06-12 16:05:22 +0000125 /**
Carsten Ziegelerc9d59452009-07-28 14:42:21 +0000126 * Set the metatype factory pid property (only for non factory components).
127 * @since 1.0
Carsten Ziegeler3bf06e02010-04-22 10:31:56 +0000128 * @deprecated Use {@link #configurationFactory()}
Carsten Ziegelerc9d59452009-07-28 14:42:21 +0000129 */
Carsten Ziegelerd88a25a2009-09-15 07:03:47 +0000130 boolean getConfigurationFactory() default false;
Carsten Ziegelerc9d59452009-07-28 14:42:21 +0000131
132 /**
Carsten Ziegeler3bf06e02010-04-22 10:31:56 +0000133 * Set the metatype factory pid property (only for non factory components).
134 * @since 1.3
135 */
136 boolean configurationFactory() default false;
137
138 /**
Carsten Ziegeler6e0c9332009-06-12 16:05:22 +0000139 * The configuration policy
140 * @since 1.0
141 */
142 ConfigurationPolicy policy() default ConfigurationPolicy.OPTIONAL;
Carsten Ziegeler5de92da2009-03-31 17:12:40 +0000143}