Java Reference
In-Depth Information
as if they're part of the parent (see figure 2.9). But they can
be installed and uninstalled independently of the host.
In this case, a translation fragment can be built and
attached to fancyfoods.web . To provide the translations,
you'll need a new fragment JAR . All it needs inside it is a
manifest and a properties file (see figure 2.10).
The French language properties file, messages_fr.prop-
erties, might read like this:
Bundle
classloader
Bundle
Attached
fragments
SayHello.hello=Bienvenue aux Aliments de Fantaisie!
The MANIFEST.MF is similar to a bundle manifest, but it
has an extra header that identifies the host of the frag-
ment— fancyfoods.web in this case. It's a good idea to also
specify a minimum version of the host bundle, to ensure
compatibility:
Figure 2.9 OSGi fragments
attach to a parent bundle
and share its classloader.
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: French language resources
Bundle-SymbolicName: fancyfoods.web.nls.fr
Bundle-Version: 1.0.0
Fragment-Host: fancyfoods.web;bundle-version="[1.0.0,2.0.0)"
Build the fragment into a JAR , fancyfoods.web.nls.fr_1.0.0.jar . After the frag-
ment is built, you can drop it into the load directory of your running framework. Type
ss and you'll see your new fragment included in the list of bundles. Fragments can't
META-INF
MANIFEST.MF
fancyfoods.web.nls.fr_1.0.0.jar
web
fancyfoods
messages_fr.properties
Figure 2.10
The layout of the fancyfoods.web.nls.fr fragment
Search WWH ::




Custom Search