Developing an OSGi application

As an introduction to developing an OSGi application, you can develop a simple HelloWorld OSGi application, which consists of two bundles. One bundle defines a hello service, and the other is a client bundle that uses this service to produce the message OSGi Service: Hello World!.

About this task

Note: OSGi application support is deprecated in WebSphere Application Server traditional because OSGi applications depend on a technology that is no longer included in Equinox 4.4.0 and later. There is no strategic alternative in WebSphere Application Server traditional. To continue to use OSGi applications, migrate your applications to Liberty. In Liberty, OSGi applications run as Subsystems, which are a standard form of OSGi application. For more information, see Migrating applications to Liberty.

An OSGi application is a Java™ application that uses OSGi technologies. OSGi applications are collections of OSGi bundles (typically bundles that use the Blueprint component model), and can expose or consume a number of services. The OSGi application described in these topics demonstrates the use of the OSGi service registry to share the hello service between the defining bundle and the client bundle. All interactions with the service registry are handled through Blueprint.

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.

Note: The steps in the following procedure are specific to this example application, and lead you through creating the application artifacts by using IBM® Rational® Application Developer or a similar tool.

Procedure

  1. Create your service bundle.
  2. Create your client bundle.
  3. Create your OSGi application.

What to do next

After you create your OSGi application, you can deploy the application to WebSphere® Application Server by using either the administrative console or wsadmin commands; for details, see Deploying an OSGi application as a business-level application.

You might also want to explore the sample OSGi applications.