OSGi™ Enterprise
Release 5

org.osgi.service.component.annotations
Annotation Type Component


@Retention(value=CLASS)
@Target(value=TYPE)
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 a Service Component Runtime implementation. 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."

Optional Element Summary
 java.lang.String configurationPid
          The configuration PID 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 containing it is started.
 java.lang.String factory
          The factory identifier of this 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.
 java.lang.Class<?>[] service
          The types under which to register this Component as a service.
 boolean servicefactory
          Declares whether this Component uses the OSGi ServiceFactory concept and each bundle using this Component's service will receive a different component instance.
 java.lang.String xmlns
          The XML name space of the Component Description for this Component.
 

name

public abstract java.lang.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."
Default:
""

service

public abstract 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

public abstract 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

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

If true, this Component uses the OSGi ServiceFactory concept. If false or not specified, this Component does not use the OSGi ServiceFactory concept.

See Also:
"The servicefactory attribute of the service element of a Component Description."
Default:
false

enabled

public abstract boolean enabled
Declares whether this Component is enabled when the bundle containing it is started.

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

See Also:
"The enabled attribute of the component element of a Component Description."
Default:
true

immediate

public abstract 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."
Default:
false

property

public abstract java.lang.String[] property
Properties for this Component.

Each property string is specified as "key=value". The type of the property value can be specified in the key as key: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 key, value pairs. For example, "foo=bar", "foo=baz".

See Also:
"The property element of a Component Description."
Default:
{}

properties

public abstract 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

public abstract 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

public abstract 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 OPTIONAL configuration policy is used.

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

public abstract java.lang.String configurationPid
The configuration PID for the configuration of this Component.

Allows the configuration PID for this Component to be different than the name of this Component.

If not specified, the name of this Component is used as the configuration PID of this Component.

Since:
1.2
See Also:
"The configuration-pid attribute of the component element of a Component Description."
Default:
""

OSGi™ Enterprise
Release 5

Copyright © OSGi Alliance (2000, 2012). All Rights Reserved. Licensed under the OSGi Specification License, Version 2.0