Java Reference
In-Depth Information
the Eclipse
IDE
. Likewise, if you use the GlassFish v3
application server, you're also using
OSG
i, because
the Apache Felix
OSG
i framework implementation is
its runtime. The diversity of use cases attests to the
value and flexibility provided by the
OSG
i framework
through three conceptual layers defined in the
OSG
i
specification (see figure 1.4):
Service
Lifecycle
Module
Figure 1.4
OSGi layered architecture
Module layer
—Concerned with packaging and
sharing code
■
Lifecycle layer
—Concerned with providing execution-time module management
and access to the underlying
OSG
i framework
■
Service layer
—Concerned with interaction and communication among modules,
specifically the components contained in them
■
Like typical layered architectures, each layer is dependent on the layers beneath it.
Therefore, it's possible for you to use lower
OSG
i layers without using upper ones, but
not vice versa. The next three chapters discuss these layers in detail, but we'll give an
overview of each here.
MODULE LAYER
The module layer defines the
OSG
i module concept, called a
bundle
, which is a
JAR
file
with extra
metadata
(data about data). A bundle contains your class files and their related
resources, as depicted in figure 1.5. Bun-
dles typically aren't an entire application
packaged into a single
JAR
file; rather,
they're the logical modules that combine
to form a given application. Bundles are
more powerful than standard
JAR
files,
because you can explicitly declare which
contained packages are externally visible
(that is,
exported packages
). In this sense,
bundles extend the normal access modifi-
ers (
public
,
private
, and
protected
)
associated with the Java language.
Another important advantage of bun-
dles over standard
JAR
files is the fact that
you can explicitly declare on which exter-
nal packages the bundles depend (that is,
imported packages
). The main benefit of
explicitly declaring your bundles'
exported and imported packages is that
the
OSG
i framework can manage and ver-
ify their consistency automatically; this
.class
Class files
.xml
.jpg
etc.
Bundle
Resource files
Manifest.mf
Metadata
Figure 1.5
A bundle contains code, resources,
and metadata.