Java Reference
In-Depth Information
org/foo/
org/foo/shape/
org/foo/shape/circle/
org/foo/shape/circle/resource/
org/foo/shape/circle/resource/Localize_de.properties
It only contains a resource file for the
German translation, which you can see
is a split package with the host bundle.
You can create any number of localiza-
tion fragments following this same pat-
tern for your other shapes (square and
triangle). Figure 5.12 shows the paint
program with the German localization
fragments installed.
To run this example, go into the
chapter05/paint-example/ directory of
the companion code and type
ant
to
build and
java
-Duser.language=de
-jar launcher.jar
bundles/
to run it
using a German locale. With this
approach, you only need to deploy the
required localization fragments along
with your shape implementations, and you can create new localizations or update exist-
ing ones without releasing new versions of the shape bundles.
We've now covered all major aspects of the
OSG
i module layer! As you can see,
tools are available to help you deal with virtually any scenario the Java language can
throw at you. But we have one more trick up our sleeves: the
OSG
i specification does a
pretty good job of dealing with native code that runs outside of the Java environment.
We'll look at this and how to deal with general factors relating to the
JVM
environment
in the next and final section of this chapter.
Figure 5.12
Paint program with installed
German localization fragments
5.5
Dealing with your environment
Although Java has been fairly successful at attaining its original vision of “write once,
run everywhere,” there are still situations where it's not entirely able to achieve this
goal. One such situation is the myriad of Java platforms, such as Java
ME
and the dif-
ferent versions of Java
SE
. If you develop a bundle with requirements for a specific Java
platform—for example, if you use classes from the
java.util.concurrent
package—
you need a Java 5.0
JVM
or above. Another situation is if you need to natively integrate
with the underlying operating system, as may be necessary if you must communicate
directly with underlying hardware.
As you may expect, in both these situations the
OSG
i specification provides mecha-
nisms to explicitly declare these scenarios in your bundles to allow an
OSG
i framework
to do whatever is necessary at execution time. In this section, we'll cover both of these
topics, starting with the former.