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
    • Element Detail

      • name

        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

        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 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."
        Default:
        false
      • enabled

        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."
        Default:
        true
      • 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. 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

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

        • 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."
        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. 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."
        Default:
        {"$"}
      • scope

        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."
        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 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."
        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 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."
        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:
        {}