Service components are described inside an XML file called a
component
descriptor (see: descriptor DTD), which is an
extension to the bundle manifest file (the component descriptor is
referenced inside the manifest through the key Metadata-Location). Inside this
descriptor,
components are declared as shown in figure 1. A bundle can contain
several components.
| <?xml version="1.0"
encoding="UTF-8"?> <bundle> <component class="org.simpleclient.impl.ServiceImpl"> <provides service="org.simpleclient.interfaces.SimpleClientServiceA"/> <provides service="org.simpleclient.interfaces.SimpleClientServiceB"/> <property name="provider" value="Beanome.org" type="string"/> <requires service="org.simpleservice.interfaces.SimpleService" filter="(version=*)" cardinality="1..n" policy="static" bind-method="setServiceReference" unbind-method="unsetServiceReference" /> </component> </bundle> |
Tag that delimits the set of components contained inside a bundle. Several components can be declared for one bundle.<component> (was <instance> in version 1.0)
Defines the class that implements the component. This class must implement all the provided service interfaces.<provides> [optional] (was<service interface="..."> in version 1.0)
One of these tags must be included for each service interface that the instance implements. If at least one these tags exist, it will result in a service registration for the defined service interfaces.<property> [optional]
One of these tags must be included for each service property. If a <provides> tag is present, the properties will used during service registration. The description of a property includes its name, value, and type (supported types are: string, boolean, byte, char, short, int, long, float, double).<requires> [optional]
One of these tags must be included for each of the instance's service dependencies. The properties of this tag are:
service: the fully qualified interface name of the required service.
filter: a filter to narrow the search (in LDAP syntax). [optional starting from 1.2]
cardinality: 0..1, 0..n, 1..1, 1..n (see: Instance management)
policy: static or dynamic (see : Instance management)
bind-method: The name of the method that is called on the implementation object when a service is connected to it. Note that this method receives as a parameter the service itself and not the OSGi service reference.
unbind-method: The name of the method that will be called on the implementation object when a service is disconnected to it. Note that this method receives as a parameter the service itself and not the OSGi service reference.
Next : Instance management
Previous : The ServiceBinder