@Retention(value=CLASS) @Target(value=TYPE) @RequireServiceComponentRuntime public @interface 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.
Modifier and Type | Fields and Description |
---|---|
static String |
NAME
Special string representing the name of this Component.
|
Modifier and Type | Optional Element and Description |
---|---|
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.
|
String |
factory
The factory identifier of this Component.
|
String[] |
factoryProperties
Factory property entries for this Factory Component.
|
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.
|
String |
name
The name of this Component.
|
String[] |
properties
Property entries for this Component.
|
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.
|
Class<?>[] |
service
The types under which to register this Component as a service.
|
boolean |
servicefactory
Deprecated.
Since 1.3. Replaced by
scope() . |
String |
xmlns
The XML name space of the Component Description for this Component.
|
public static final String NAME
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.
public abstract String name
If not specified, the name of this Component is the fully qualified type name of the class being annotated.
public abstract Class<?>[] 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.
public abstract String factory
If not specified, the default is that this Component is not a Factory Component.
public abstract boolean servicefactory
scope()
.
This element is ignored when the scope()
element does not have
the default value. If true
, this Component uses
bundle
service scope. If false
or not
specified, this Component uses singleton
service scope. If the factory()
element is specified or the
immediate()
element is specified with true
, this element
can only be specified with false
.
public abstract boolean enabled
If true
or not specified, this Component is enabled. If
false
, this Component is disabled.
public abstract boolean immediate
If true
, this Component must be immediately activated upon
becoming satisfied. If false
, activation of this Component is
delayed. If this property is specified, its value must be false
if the factory()
property is also specified or must be
true
if the service()
property is specified with an
empty value.
If not specified, the default is false
if the factory()
property is specified or the service()
property is not specified
or specified with a non-empty value and true
otherwise.
public abstract String[] property
Each property string is specified as "name=value"
. The type of
the property value can be specified in the name as
name:type=value
. The type must be one of the property types
supported by the type
attribute of the property
element
of a Component Description.
To specify a property with multiple values, use multiple name, value
pairs. For example, {"foo=bar", "foo=baz"}
.
public abstract String[] properties
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.
public abstract String xmlns
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.
public abstract ConfigurationPolicy configurationPolicy
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.
public abstract String[] configurationPid
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. The NAME
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.
public abstract ServiceScope scope
If not specified (and the deprecated servicefactory()
element is
not specified), the singleton
service
scope is used. If the factory()
element is specified or the
immediate()
element is specified with true
, this element
can only be specified with the singleton
service scope.
public abstract Reference[] reference
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 the locateService
methods of ComponentContext
.
To access references using method injection, bind methods are annotated
with Reference
. To access references using field injection,
fields are annotated with Reference
. To access references using
constructor injection, constructor parameters are annotated with
Reference
.
public abstract String[] factoryProperty
Each factory property string is specified as "name=value"
. The
type of the factory property value can be specified in the name as
name:type=value
. The type must be one of the factory property
types supported by the type
attribute of the
factory-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.
public abstract String[] factoryProperties
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.
Copyright © Contributors to the Eclipse Foundation Licensed under the Eclipse Foundation Specification License – v1.0