...
iPOJO is a component model on the top of OSGi? OSGi™ aiming to simplify the development of OSGi? OSGi™ applications. Moreover, iPOJO provide an extensibility mechanism allowing developers to extend the component model.
...
A composite can be represented as a service registry. Moreover, composite can be contained in other composite. The OSGi? OSGi™ service registry is the root composite.
...
To illustrate the composition we will design a Hello World application named HelloComposition. This application offers a service writing a Hello message for each imported Person. Each person is published as a service and is used by the composition to write the message.
The application provides the HelloDispatcher service :
...
- an Hello Service : returning a Hello message
- a Directory service : aggregating Person services to create a Directory
- a Dispatch Service : requiring an Hello Service and a Directory Service to write Hello Service to person contained in the Directory.
An "instantiable" service is a service that we can instantiate through a Factory. The following code snippets show the different service specification:
Code Block |
---|
public interface Hello {
public void hello(String name);
public String getLanguage();
}
|
Code Block |
---|
public interface Directory {
public Person getPerson(String name);
public List<Person> getPersons();
public void addPerson(String name, String adress);
public void removePerson(String name);
}
|
Code Block |
---|
public interface Person {
public String getName();
public String getAddress();
}
|
Code Block |
---|
public interface Dispatch{
public void say();
}
|
So to design our application we will use these services to obtain the following applications.
Application Description
To describe our application, we will use the iPOJO ADL:
...
- Imports all available Person service in the parent composite.
- Provides the Hello Dispatch to the parent composite.
- Instantiates inside the composition a Hello service, a Dispatcher Service and a Directory Service.
The providing is based on a method delagation on available specifications as depict in the following image :
Packaging
A composite is described in the metadata.xml file of an iPOJO bundle. It is possible to create an instance of the composition in this file:
...