Java Reference
In-Depth Information
Figure 6.5
JAR-to-bundle cheat sheet
OK
, you know how to take a single
JAR
file and turn it into a bundle, but what about a
complete application? You could take your existing
JAR
,
EAR
, and
WAR
files and turn
them all into bundles; or you could choose to wrap everything up as a single application
bundle. Surely you can do better than that. What techniques can you use to bundle up
an application, and what are the pros and cons? For the answers to this and more, read on.
6.2
Splitting an application into bundles
Most applications are made up of one or more
JAR
files. One way to migrate an appli-
cation to
OSG
i is to take these individual
JAR
files and convert each of them into a
bundle using the techniques discussed in the previous section. Converting lots of
JAR
files is time consuming (especially for beginners), so a simpler approach is to take
your complete application and wrap it up as a single bundle. In this section, we'll show
you how to start from such a single application bundle and suggest ways of dividing it
further into multiple bundles. Along the way, we'll look at how you can introduce
other
OSG
i features, such as services, to make your application more flexible. Finally,
we'll suggest places where it doesn't make sense to introduce a bundle.
Let's start with the single application bundle or so-called
mega bundle
.
6.2.1
Making a mega bundle
A mega bundle comprises a complete application along with its dependencies. Any-
thing the application needs on top of the standard
JDK
is embedded inside this bundle