- to create open specifications for the
network delivery of managed services to
local networks and devices.
2.1 The Framework Specification
The OSGi framework is designed to create
extensible services using the Java programming
language, which provides execution environment for
the needed services. The OSGi framework must
provide a consistent programming model during
application development. The execution
environment extends it with the lifecycle
management, service registry, persistent data storage
and version management.
The OSGi framework provides the lifecycle
management that allows the developers to divide the
applications into self-installable components. These
components are called bundle.
Bundles can be downloaded on demand and
removed when they are no longer needed. When a
bundle is installed and activated in the framework, it
can register any number of services that can be used
by other bundles. This dynamic aspect makes the
software extensible on the device after deployment:
new bundles can be installed for added features or
existing bundles can be updated for bug fixes.
The developers design an application as a set of
bundles that contain services, with each service
implementing a segment of the overall functionality.
The entities in the framework are:
- Services, the Java classes that perform certain
functionality, usually written with interface and its
implementation separated. A service is a self
contained component, accessible via a defined
service interface. In the OSGi model, an application
is built around a set of cooperating services: it can
extend its functionality at runtime by requesting
more services which it requires. The framework
maintains a set of mappings from services to their
implementations and has a simple query mechanism
(LDAP based syntax) that enables an installed
service to request and use the available services. The
Framework manages the dependencies among
services. A developer defines a service as an
interface and provides its implementation. Then she
can register the service with the Framework. When a
service is registered, it can be given a set of
properties (name/value pairs) to enable a
sophisticated retrieval based on LDAP attribute
comparisons.
After a service is published, other services can
use it to accomplish their tasks; they look up the
service from the framework with a search filter, and
will get back the matching service references. The
service reference can then be used to get a Java
object that implements the desired service. The
framework does not actually give out references to
objects implementing a service directly, which
would also instantly create a dynamic dependency
on the bundle providing the service. Instead, it gives
out a ServiceReference object, which can be
stored and passed on to other bundles, without the
implications of dependencies. When the service is
actually to be used by a bundle, a reference to the
implementing object can be obtained from the
current BundleContext, passing it the
ServiceReference.
- Bundles, the functional and deployment unit
for shipping services. A bundle is a JAR (Java
Archive) file that:
- contains the resources to implement zero or
more services.
- contains a manifest file describing the
content of the JAR and providing
information about the bundle.
- states dependencies on other resources,
such as Java packages, that must be
available to the bundle before it can run.
The framework must resolve these
packages prior to starting a bundle.
- designates a special class in the bundle to
act as bundle activator. The framework
must instantiate this class and invokes the
start and stop methods to start or stop the
bundle respectively.
- can contain optional documentation within
the JAR. This can be used to store the
source code of a bundle. Management
systems may remove this information to
save storage spaces.
When a bundle is already started, its
functionality is provided and services are exposed to
other bundles installed in the OSGi environment.
They can then use the framework to access this
functionality. For each bundle installed in the
framework, there is an associated bundle object.
This object is used to manage the namespace of the
bundle's Java classes, by directing the loading and
resolution of those classes. By establishing separate
namespaces for bundles, class-name conflicts among
bundles are avoided.
The framework provides its scoping as an
additional precaution: if two bundles have class
names in common, the fact that those names are
scoped by different bundle namespaces means that
there is no contention. A bundle is used to get
information about the current bundle lifecycle status
and to start, stop and update bundles.
WEBIST 2005 - INTERNET COMPUTING
100