Java Reference
In-Depth Information
Figure 2.8 If the Geronimo servlet bundle is removed from the runtime, the fancyfoods.web bundle
can't be started, because no servlet API is present.
ss to see the list of bundles. You'll see a number of bundles, including fancyfoods.web ,
are in the INSTALLED state instead of the ACTIVE state. This means the bundles couldn't
be resolved or started because some dependencies were missing. Make a note of the bun-
dle identifier to the left of fancyfoods.web in the bundle list. Try starting the bundle
to see what happens. See figure 2.8.
Because your assembly no longer has servlet support, fancyfoods.web won't start.
The bundle definitely wouldn't work properly if the code inside it was to run, so not
starting is the right behavior. Don't forget to put the Geronimo servlet bundle back
into the target directory before you try to use the web application again. (The authors
forgot to do this on several occasions, and were confused each time.)
FRAGMENTS
OSG i bundles have a third advantage over normal WAR s. OSG i is all about modularity,
and so OSG i bundles can themselves have modular extensions, known as fragments .
Fragments are extensions to bundles that attach to a host bundle and act in almost
every way as if they were part of the host. They allow bundles to be customized
depending on their environment. For example, translated resource files can be pack-
aged up by themselves into a fragment and only shipped if needed. Fragments can
also be used to add platform-specific code to a generic host.
2.2.4
Spicing things up with fragments
How would a fragment work with your little application? The first version of the
fancyfoods.web application is only intended to work in English, but if the business
takes off, it will expand into other markets. The first step in internationalizing
fancyfoods.web is to externalize the strings in SayHello.java . Write a properties
file called fancyfoods/web/messages.properties with the following content:
SayHello.hello=Hello valued customer!
The new doGet method looks like the following.
Search WWH ::




Custom Search