Top Description Fields Methods
org.osgi.service.component.annotations

public @Interface Component

extends Annotation
Annotations
@Retention:CLASS
@Target:TYPE
@RequireServiceComponentRuntime
Imports
java.lang.annotation.ElementType, .Retention, .RetentionPolicy, .Target

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.

Author
$Id: 630efc2d8136ae32c756971c01ed67aa8bcea57c $
See Also
The component element of a Component Description.

Field Summary

Modifier and TypeField and Description
public static final String
NAME

Special string representing the name of this Component.

Method Summary

Modifier and TypeMethod and Description
public String[]
configurationPid()

The configuration PIDs for the configuration of this Component.

public ConfigurationPolicy
configurationPolicy()

The configuration policy of this Component.

public boolean
enabled()

Declares whether this Component is enabled when the bundle declaring it is started.

public String
factory()

The factory identifier of this Component.

public String[]
factoryProperties()

Factory property entries for this Factory Component.

public String[]
factoryProperty()

Factory properties for this Factory Component.

public boolean
immediate()

Declares whether this Component must be immediately activated upon becoming satisfied or whether activation should be delayed.

public String
name()

The name of this Component.

public String[]
properties()

Property entries for this Component.

public String[]
property()

Properties for this Component.

public Reference[]
reference()

The lookup strategy references of this Component.

public ServiceScope
scope()

The service scope for the service of this Component.

public Class<?>[]
service()

The types under which to register this Component as a service.

public boolean
servicefactory()
Deprecated Since 1.3. Replaced by scope().

Declares whether this Component uses the OSGi ServiceFactory concept and each bundle using this Component's service will receive a different component instance.

public String
xmlns()

The XML name space of the Component Description for this Component.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Field Detail

NAMEback to summary
public static final 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

Method Detail

configurationPidback to summary
public 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. 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.
Since
1.2
See Also
The configuration-pid attribute of the component element of a Component Description.
configurationPolicyback to summary
public 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.

  • Not annotated with Designate - The configuration policy is OPTIONAL.
  • Annotated with Designate(factory=false) - The configuration policy is OPTIONAL.
  • Annotated with Designate(factory=true) - The configuration policy is REQUIRE.
Since
1.1
See Also
The configuration-policy attribute of the component element of a Component Description.
enabledback to summary
public boolean enabled()

Declares whether this Component is enabled when the bundle declaring it is started.

If true or not specified, this Component is enabled. If false, this Component is disabled.

See Also
The enabled attribute of the component element of a Component Description.
factoryback to summary
public 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.
factoryPropertiesback to summary
public 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.
factoryPropertyback to summary
public 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 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.

Since
1.4
See Also
The factory-property element of a Component Description.
immediateback to summary
public 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. 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.

See Also
The immediate attribute of the component element of a Component Description.
nameback to summary
public String name()

The name of this Component.

If not specified, the name of this Component is the fully qualified type name of the class being annotated.

See Also
The name attribute of the component element of a Component Description.
propertiesback to summary
public 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.
propertyback to summary
public 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 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"}.

See Also
The property element of a Component Description.
referenceback to summary
public 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 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.

Since
1.3
See Also
The reference element of a Component Description.
scopeback to summary
public ServiceScope scope()

The service scope for the service of this Component.

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.

Since
1.3
See Also
The scope attribute of the service element of a Component Description.
serviceback to summary
public 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.
servicefactoryback to summary
public boolean servicefactory()

Deprecated

Since 1.3. Replaced by scope().

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. 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.

See Also
The scope attribute of the service element of a Component Description.
xmlnsback to summary
public 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.