Java Reference
In-Depth Information
options in chapter 13. In the meantime, the sandbox is a good environment for play-
ing with various bits of enterprise
OSG
i. We'll start with the public face of almost any
enterprise application, the web frontend.
2.2
Writing an OSGi web application
In Java
EE
the servlet and JavaServer Pages models have provided the basic building
blocks for Java web applications for many years.
OSG
i web applications are a standard-
ized
OSG
i version of Java
EE
web applications. An
OSG
i web bundle is similar to a Java
EE
WAR
, except that it also gets the benefits of operating in an
OSG
i framework. Enter-
prise
OSG
i web bundles are known as
WAB
s. (In contrast to
WAR
s, which are
Web
Archives
,
WAB
s are
Web Application Bundles
.)
2.2.1
Building a simple OSGi web application bundle
Let's give
WAB
s a try. You can use your favorite
OSG
i or Java
EE
development tools. All
you need for now is the ability to compile Java code and build
JAR
s. (We'll cover spe-
cialist enterprise
OSG
i development tools in chapter 8. Feel free to peek ahead now if
you're struggling to make
OSG
i
JAR
s.)
WAB LAYOUTS
The simplest
WAB
contains three files. These are a Java servlet class, a
JAR
manifest,
and a web deployment descriptor. Figure 2.4 shows how they're laid out in the
WAB
.
Like
WAR
s,
WAB
s are a special kind of
JAR
. Unlike
WAR
s, the enterprise
OSG
i specifica-
tion doesn't require a particular file extension. As a result,
WAB
files may have any
META-INF
MANIFEST.MF
fancyfoods.web_1.0.0.jar
WEB-INF
web.xml
classes
Figure 2.4
The layout of the
fancyfoods.web
JAR. All code lives in WEB-INF/classes. The
web container looks at WEB-INF/web.xml to find out what servlets are provided by the bundle.
Finally, the standard JAR manifest, META-INF/MANIFEST.MF includes important extra metadata
for the OSGi container.






























































