Network Deployment (Distributed operating systems), v8.0 > Develop and deploying applications > Develop OSGi applications
Develop 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.
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 v8 or similar tooling. The final step is not specific to this example application, and describes the process of deploying any OSGi application in WAS, using the administrative console or wsadmin commands.
Procedure
- Create your service bundle.
- Create your client bundle.
- Create your OSGi application.
- 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.
You might also want to explore the sample OSGi applications.
Subtopics
- Create a service bundle
For the simple hello-world OSGi application, the service bundle declares the HelloWorldEBA interface, and exports it as an OSGi service.- Create a client bundle
For the simple hello-world OSGi application, the client bundle consumes the HelloWorldEBA service, and uses it to produce the message "OSGi Service: Hello World!".- Create an OSGi application
For the simple hello-world OSGi application, the bundle that defines the service, and the bundle that uses the service, are packaged together in an OSGi application.- Deploy an OSGi application as a business-level application
Import an OSGi application as an enterprise bundle archive (EBA) asset, then add the asset to a business-level application by creating a composition unit. Optionally, add a composite bundle extension to the composition unit.- Debug bundles at run time using the command-line console
We can use the wsadmin-based OSGi Applications command-line console to explore or debug the bundles associated with a specific OSGi application or shared bundle framework.
Parent topic: Develop OSGi applications
Related concepts:
About OSGi Applications
The Blueprint Container
The WebSphere programming model and OSGiRelated tasks:
Secure OSGi Applications
Develop a composite bundleRelated reference:
Best practices for developing and working with OSGi applications
Develop enterprise OSGi applications for WAS
OSGi Applications: Troubleshooting tips
Task topic Feedback
Copyright IBM Corporation 2009, 2011. All Rights Reserved.
This information center is powered by Eclipse technology.