Annotation Type Component
-
@Retention(CLASS) @Target(TYPE) @RequireServiceComponentRuntime public @interface Component
Identify the annotated class as a Service Component.The annotated class is the implementation class of the Component.
This annotation is not processed at runtime by Service Component Runtime. It must be processed by tools and used to add a Component Description to the bundle.
- See Also:
- "The component element of a Component Description."
-
-
Field Summary
Fields Modifier and Type Fields Description static java.lang.String
NAME
Special string representing the name of this Component.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.String[]
configurationPid
The configuration PIDs for the configuration of this Component.ConfigurationPolicy
configurationPolicy
The configuration policy of this Component.boolean
enabled
Declares whether this Component is enabled when the bundle declaring it is started.java.lang.String
factory
The factory identifier of this Component.java.lang.String[]
factoryProperties
Factory property entries for this Factory Component.java.lang.String[]
factoryProperty
Factory properties for this Factory Component.boolean
immediate
Declares whether this Component must be immediately activated upon becoming satisfied or whether activation should be delayed.java.lang.String
name
The name of this Component.java.lang.String[]
properties
Property entries for this Component.java.lang.String[]
property
Properties for this Component.Reference[]
reference
The lookup strategy references of this Component.ServiceScope
scope
The service scope for the service of this Component.java.lang.Class<?>[]
service
The types under which to register this Component as a service.boolean
servicefactory
Deprecated.Since 1.3.java.lang.String
xmlns
The XML name space of the Component Description for this Component.
-
-
-
Field Detail
-
NAME
static final java.lang.String NAME
Special string representing the name of this Component.This string can be used in
configurationPid()
to specify the name of the component as a configuration PID. For example:@Component(configurationPid={"com.acme.system", Component.NAME})
Tools creating a Component Description from this annotation must replace the special string with the actual name of this Component.- Since:
- 1.3
-
-
-
service
java.lang.Class<?>[] service
The types under which to register this Component as a service.If no service should be registered, the empty value
{}
must be specified.If not specified, the service types for this Component are all the directly implemented interfaces of the class being annotated.
- See Also:
- "The service element of a Component Description."
- Default:
- {}
-
-
-
factory
java.lang.String factory
The factory identifier of this Component. Specifying a factory identifier makes this Component a Factory Component.If not specified, the default is that this Component is not a Factory Component.
- See Also:
- "The factory attribute of the component element of a Component Description."
- Default:
- ""
-
-
-
servicefactory
boolean servicefactory
Deprecated.Since 1.3. Replaced byscope()
.Declares whether this Component uses the OSGi ServiceFactory concept and each bundle using this Component's service will receive a different component instance.This element is ignored when the
scope()
element does not have the default value. Iftrue
, this Component usesbundle
service scope. Iffalse
or not specified, this Component usessingleton
service scope. If thefactory()
element is specified or theimmediate()
element is specified withtrue
, this element can only be specified withfalse
.- See Also:
- "The scope attribute of the service element of a Component Description."
- Default:
- false
-
-
-
immediate
boolean immediate
Declares whether this Component must be immediately activated upon becoming satisfied or whether activation should be delayed.If
true
, this Component must be immediately activated upon becoming satisfied. Iffalse
, activation of this Component is delayed. If this property is specified, its value must befalse
if thefactory()
property is also specified or must betrue
if theservice()
property is specified with an empty value.If not specified, the default is
false
if thefactory()
property is specified or theservice()
property is not specified or specified with a non-empty value andtrue
otherwise.- See Also:
- "The immediate attribute of the component element of a Component Description."
- Default:
- false
-
-
-
property
java.lang.String[] property
Properties for this Component.Each property string is specified as
"name=value"
. The type of the property value can be specified in the name asname:type=value
. The type must be one of the property types supported by thetype
attribute of theproperty
element of a Component Description.To specify a property with multiple values, use multiple name, value pairs. For example,
{"foo=bar", "foo=baz"}
.- See Also:
- "The property element of a Component Description."
- Default:
- {}
-
-
-
properties
java.lang.String[] properties
Property entries for this Component.Specifies the name of an entry in the bundle whose contents conform to a standard Java Properties File. The entry is read and processed to obtain the properties and their values.
- See Also:
- "The properties element of a Component Description."
- Default:
- {}
-
-
-
xmlns
java.lang.String xmlns
The XML name space of the Component Description for this Component.If not specified, the XML name space of the Component Description for this Component should be the lowest Declarative Services XML name space which supports all the specification features used by this Component.
- See Also:
- "The XML name space specified for a Component Description."
- Default:
- ""
-
-
-
configurationPolicy
ConfigurationPolicy configurationPolicy
The configuration policy of this Component.Controls whether component configurations must be satisfied depending on the presence of a corresponding Configuration object in the OSGi Configuration Admin service. A corresponding configuration is a Configuration object where the PID equals the name of the component.
If not specified, the configuration policy is based upon whether the component is also annotated with the Meta Type
Designate
annotation.- Since:
- 1.1
- See Also:
- "The configuration-policy attribute of the component element of a Component Description."
- Default:
- org.osgi.service.component.annotations.ConfigurationPolicy.OPTIONAL
-
-
-
configurationPid
java.lang.String[] configurationPid
The configuration PIDs for the configuration of this Component.Each value specifies a configuration PID for this Component.
If no value is specified, the name of this Component is used as the configuration PID of this Component.
A special string (
"$"
) can be used to specify the name of the component as a configuration PID. TheNAME
constant holds this special string. For example:@Component(configurationPid={"com.acme.system", Component.NAME})
Tools creating a Component Description from this annotation must replace the special string with the actual name of this Component.- Since:
- 1.2
- See Also:
- "The configuration-pid attribute of the component element of a Component Description."
- Default:
- {"$"}
-
-
-
scope
ServiceScope scope
The service scope for the service of this Component.If not specified (and the deprecated
servicefactory()
element is not specified), thesingleton
service scope is used. If thefactory()
element is specified or theimmediate()
element is specified withtrue
, this element can only be specified with thesingleton
service scope.- Since:
- 1.3
- See Also:
- "The scope attribute of the service element of a Component Description."
- Default:
- org.osgi.service.component.annotations.ServiceScope.DEFAULT
-
-
-
reference
Reference[] reference
The lookup strategy references of this Component.To access references using the lookup strategy,
Reference
annotations are specified naming the reference and declaring the type of the referenced service. The referenced service can be accessed using one of thelocateService
methods ofComponentContext
.To access references using method injection, bind methods are annotated with
Reference
. To access references using field injection, fields are annotated withReference
. To access references using constructor injection, constructor parameters are annotated withReference
.- Since:
- 1.3
- See Also:
- "The reference element of a Component Description."
- Default:
- {}
-
-
-
factoryProperty
java.lang.String[] factoryProperty
Factory properties for this Factory Component.Each factory property string is specified as
"name=value"
. The type of the factory property value can be specified in the name asname:type=value
. The type must be one of the factory property types supported by thetype
attribute of thefactory-property
element of a Component Description.To specify a factory property with multiple values, use multiple name, value pairs. For example,
{"foo=bar", "foo=baz"}
.If specified, the
factory()
element must also be specified to indicate the component is a Factory Component.- Since:
- 1.4
- See Also:
- "The factory-property element of a Component Description."
- Default:
- {}
-
-
-
factoryProperties
java.lang.String[] factoryProperties
Factory property entries for this Factory Component.Specifies the name of an entry in the bundle whose contents conform to a standard Java Properties File. The entry is read and processed to obtain the factory properties and their values.
If specified, the
factory()
element must also be specified to indicate the component is a Factory Component.- Since:
- 1.4
- See Also:
- "The factory-properties element of a Component Description."
- Default:
- {}
-
-