Developing and deploying an OSGi application

As an introduction to developing an OSGi application, you can develop a simple hello-world 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

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. A single OSGi application is packaged in an enterprise bundle archive (.eba) file, just as an enterprise application is packaged in an enterprise archive (.ear) file. 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: In the following procedure, the first three steps are specific to this example application, and lead you through creating the application artefacts using IBM® Rational® Application Developer Version 8. The final step is not specific to this example application, and describes the process of deploying any OSGi application in WebSphere® Application Server, using the administrative console or wsadmin commands.

Procedure

  1. Create your service bundle.
  2. Create your client bundle.
  3. Create your OSGi application.
  4. Deploy an OSGi application as a business-level application.

What to do next

To help solve any unexpected problems with your deployed applications, you can debug the bundles at run time using the command-line console.

As well as creating the simple hello-world OSGi application, you might also want to explore the "blabber" and "blog" sample OSGi applications.

The following lab exercise shows you how to make a change to one of the bundles in the hello-world OSGi application, and redeploy it to propagate the change: Modify and redeploy a single bundle from an application to update it without redeploying the application.


Icon that indicates the topic type Task topic

Terms and conditions for information centers | Feedback


Timestamp icon Last updated: Saturday, 20 October 2012
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=v700osgijpa&product=was-nd-mp&topic=thread_ta_dev_devdepeba

Copyright IBM Corporation 2009, 2012.
This information center is powered by Eclipse technology. (http://www.eclipse.org)