name: The name would help you search the configuration in OSGi’s configuration manager.

Add @Designate to the Component that would consume the configurations. The ocd attribute should refer to the Configuration interface created in Step-2.

Declare properties that you would like to configure via @AttributeDefinition

Following image maps annotation attributes with the OSGi UI.

Please note that there are 2 ways to define default values:

defaultValue attribute of @AttributeDefinition: The value is displayed to the user, when he/she tries to configure the interface via Configuration manager. OSGi will NOT pick this default value, if no Configuration exists. Thus, when you install a bundle, the output would appear as:

Specifying default value in variable declarartion: The value is displayed to the user, when he/she tries to configure the interface via Configuration manager. OSGi will pick this default value, even if no Configuration exists.

Also, note that we no longer need PropertiesUtil to resolve OSGi configurations. 🙂

Notes:

Via Declarative Services, the number of annotations have been reduced. For example: @Component annotation is used for:

Component

Service

Servlet

Filter etc..

All of the above can be created by utilizing attributes of @Component details. More details are available on specific links