< Previous | Next >

Lesson 1: Create the bundle and application

An OSGi bundle is a Java™ archive file that contains Java code, resources, and a manifest that describes the bundle and its dependencies. An OSGi bundle contains the business logic and metadata that you need to run a service. A bundle is a module in an application, which in turn is deployed to a server.

About this task

An OSGi application project groups a set of bundles to provide a coherent business logic. The application can consist of different bundle types such as web enabled bundles and persistence (JPA) enabled bundles.

In this lesson, you create an OSGi bundle that contains OSGi Blueprint information that defines a service that provides a plain old Java object (POJO) component assembly model. A POJO is an ordinary Java object, as distinguished from a special Java object, such as an enterprise entity bean.

To create the bundle, CounterServiceBundle:

Procedure

  1. Click File > New > Other and then expand OSGi.
  2. Click OSGi Bundle Project and then click Next. The New OSGi Bundle Project opens.
  3. In the Project name field, type CounterServiceBundle.
  4. In the Target runtime list, select one of the following servers:
    • WebSphere Application Server v7.0
    • WebSphere Application Server v8.0
    • WebSphere Application Server v8.5
    • WebSphere Application Server V8.5 Liberty
  5. In the Application project field, change the name of your application project to CounterApp and then click Finish.

Results

Your OSGi bundle project is created and a bundle manifest is added to your project. Your OSGi application project is also created and your application manifest is added to the project. The application manifest file contains metadata that enables the OSGi Framework to process the modular aspects of the bundles. For more information about the OSGi application manifest file, see Application manifest files.

Your OSGi bundle project and application.
Learn more about the bundle manifest file:
To view the bundle manifest, expand your project and then double-click Manifest: CounterServiceBundle. The bundle manifest opens in the editor. The bundle manifest source looks similar to the following example:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CounterServiceBundle
Bundle-SymbolicName: CounterServiceBundle
Bundle-Version: 1.0.0
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
The OSGi bundle manifest file contains metadata that enables the OSGi Framework to process the modular aspects of the bundle. For more information about the OSGi bundle manifest file, see OSGi bundle manifest file.
Learn more about the application manifest:
To view the application manifest, double-click Manifest:CounterApp to open your application manifest in the editor. The application manifest looks similar to the following example:
Application-Name: CounterApp
Application-SymbolicName: CounterApp
Application-ManifestVersion: 1.0
Application-Version: 1.0.0
Manifest-Version: 1.0
Application-Content: CounterServiceBundle;version=1.0.0,

Application-SymbolicName is the OSGi application name. Application-Content lists the bundle names with the acceptable range of OSGi version specifications. In this tutorial, the bundle CounterServiceBundle is tolerated with a version of 1.0 or later.

Important: There must be a carriage return at the end of the last line of the APPLICATION.MF file.

For more information about the OSGi application manifest file, see Application manifest files.

Lesson checkpoint

You created the CounterServiceBundle bundle and the CounterApp application.

In this lesson, you learned about the following topics:
  • How to create an OSGi bundle project and OSGi application project.
  • About the bundle manifest file.
  • About the application manifest file.
< Previous | Next >
Icon that indicates the type of topic Tutorial lesson topic
Timestamp icon Last updated: July 17, 2017 21:58

File name: counter_lesson1.html