922 WebSphere Application Server V8.5 Administration and Configuration Guide for the Full Profile
26.1 OSGi overview
Open Services Gateway initiative (OSGi) is a framework based on Java technology. OSGi
enables you to write modular, dynamic, and versioning applications. WebSphere Application
Server V8.5 uses the Eclipse Equinox as the framework for OSGi applications and OSGi
V4.2.
You can design and build applications from coherent, versioned, reusable OSGi modules that
are accessed only through well-defined interfaces. The new features of WebSphere
Application Server V8.5 support for OSGi applications includes the following list:
An OSGi application can contain Enterprise JavaBean (EJB) that allows direct access and
invokes an enterprise bean.
A blueprint configuration file can specify a user role for security access to the methods of
the bean.
The OSGi framework in WebSphere Application Server provides support for each of the
layers of the OSGi Architecture:
The Modules layer
The Life-cycle layer
The Services layer
We discuss each of them in following sections.
26.1.1 OSGi application model
This section covers OSGi deployment, metadata, and the dependencies and capabilities of
OSGi through versioning.
OSGi bundles and bundle archives
The unit of deployment in OSGi is a bundle. A bundle is a standard JAR or WAR file with
additional metadata in the manifest file. Because the standard Java environment ignores
these additional properties, you can also use an OSGi bundle with classic Java applications.
There are several bundles and bundle archives within an OGSi application:
Enterprise bundle archives
An
enterprise bundle archive file contains a set of OSGi bundles that are deployed as a
single OSGi application and isolated from other OSGi applications. Bundles that belong to
an OSGi application can reference other bundles that are in the shared bundle repository.
The external bundles referenced do not have to be included within the application as long
as the originating bundles import the required packages and the external bundles export
these packages as well.
Composite bundles
A composite bundle actively groups shared bundles together into a
composite bundle
archive
file. This grouped bundle acts as a single bundle from the user perspective. It
provides one or more packages at
exact versions (not a version range) to an OSGi
application. When the OSGi framework resolves a package to a bundle within a composite
bundle archive, it has the affinity to resolve the remainder of the packages within the same
composite bundle archive.
Chapter 26. Working with OSGi applications 923
Application bundles and shared bundles
Application bundles are instance-specific or
isolated, and each instance of an application
includes its own instance of the bundle. Shared bundles are
shared or not
instance-specific, and a single instance of a package or service from a shared bundle can
be used by many applications.
Web application bundles
A
web application bundle is a bundle that contains a web application and that can be
deployed in an OSGi container.
EJB bundles
An EJB bundle is a bundle that contains EJBs and that can be deployed in an OSGi
container. An EJB bundle is an OSGi bundle version of an EJB JAR file. It is a new feature
introduced in WebSphere Application Server V8.5.
For more information about OSGi bundles and bundle archives, refer to the following website:
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=phil&product=was-nd
-dist&topic=ca_bundles
OSGi Bundle Manifest file
The metadata for an OSGi application is defined in manifest files. An OSGi bundle contains a
bundle manifest. A composite bundle archive contains a composite bundle manifest. An
enterprise bundle archive contains an application manifest. An enterprise bundle archive
asset contains a deployment manifest which is generated automatically when the enterprise
bundle archive file is imported as an asset.
In this section we focus on the OSGi bundle manifest located under META-INF/MANIFEST.MF.
For other manifest information, refer to the following website:
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=phil&product=was-nd
-dist&topic=ca_manifest
We now check each element of the example manifest shown as Example 26-1.
Example 26-1 An example of bundle manifest file, META-INF/MANIFEST.MF
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MyLibrary bundle
Bundle-SymbolicName: com.sample.mylibrary
Bundle-Version: 42.0.0
Bundle-Activator: com.sample.mylibrary.Activator
Import-Package: org.osgi.framework;version=”[1.0.0,2.0.0)”
Export-Package:
com.sample.mylibrary.stringops;version=23.2.1,com.sample.mylibrary.integerops;ver
sion=5.0.0
Meta-Persistence: entities/persistence.xml,
lib/thirdPartyEntities.jar!/META-INF/persistence.xml
Web-ContextPath: /contextRoot
Export-EJB:
Bundle-Blueprint: /blueprint/*.xml

Get WebSphere Application Server V8.5 Administration and Configuration Guide for the Full Profile now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.