concept service property in category osgi

This is an excerpt from Manning's book OSGi in Depth.
Service properties —A map of key-value pairs that can be used to provide metadata to the service is optional.
Service properties are key-value pairs that are associated with service objects to act as metadata. The metadata is generally used to find a service of interest in the OSGi service registry. A common example of a service property is a text description of the service.
We can use the service properties to describe the terms of the auction. The buyers and sellers can then search the OSGi service registry for the auction service object whose service properties meet the criteria of terms desired.
Let’s define two auction terms, the auction type and the auction duration, and model these terms as service properties. OSGi service property keys must be of Java String type. The service property value can be any Java object, but it’s advisable to only use Java primitive or standard types, such as the Collection classes in the java.util package.
Figure 3.3. An OSGi LDAP filter that uses service properties reformatted to infix format and uses the descriptive AND instead of &
![]()
Hopefully it looks less puzzling now. The filter expression searches for service objects that have a service property named auction-type whose value must be equal to the string "English" and a service property auction-duration whose value must be equal to the number 50. The comparison of the service property name is case insensitive, but the comparison of their values is dependent on their type. As a general rule of thumb, the comparison of the service property values relies on the equal method of the value’s Java class. We’ll discuss OSGi’s filter expression in detail in chapter 5.