For the simple HelloWorld OSGi application, the bundle that defines the service and the bundle that uses the service are packaged together in an OSGi application.
You can create your application as described in this topic, in which case the application manifest file is created for you by the tooling, or you can create your application using Apache Ant.
OSGi bundles are packaged as Java™ archive (JAR) files with a .jar extension. A single OSGi application is packaged in an enterprise bundle archive (EBA) file with a .eba extension, just as an enterprise application is packaged in an enterprise archive (EAR) file with a .ear extension. In this example application, the bundles are packaged directly in the EBA file. However, the EBA file does not have to contain the bundles; they can be pulled in at run time. For an OSGi application deployed to WebSphere® Application Server, a bundle can be located in the EBA file, or in the WebSphere Application Server internal bundle repository, or in an external bundle repository. Every EBA file contains an application manifest file, called APPLICATION.MF, that contains the metadata that defines the application. It lists the bundles that the application uses, and says where each bundle is located.
Rational® Application Developer Version 8.5 provides graphical support for creating and packaging bundles. The sample procedure that follows uses this tool. You can also use other tools, and the steps are adaptable to other tools.
This sample procedure creates a simple hello-world OSGi application called , in which the three bundles , and are packaged together in an .eba file.
When you deploy and start this application, it prints the greeting message OSGi Service: Hello World! to the system output log.
To create the application, complete the following steps:
[4/15/10 14:07:33:295 GMT] 00000023 SystemOut O Client: Start...
[4/15/10 14:07:33:581 GMT] 00000023 SystemOut O OSGi Service: Hello World!
[4/15/10 14:07:33:581 GMT] 00000023 SystemOut O Client: End...