@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 java.lang.String |
NAME
Special string representing the name of this Component.
|
Modifier and Type | Optional Element and 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. Replaced by
scope() . |
java.lang.String |
xmlns
The XML name space of the Component Description for this Component.
|
public static final java.lang.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 java.lang.String name
If not specified, the name of this Component is the fully qualified type name of the class being annotated.
public abstract java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 © OSGi Alliance (2000, 2018). All Rights Reserved. Licensed under the OSGi Specification License, Version 2.0