Java Reference
In-Depth Information
For example, consider this rather obscure command on Linux:
$ java -jar ../../lib/bnd-0.0.384.jar print jEdit/*.jar \
| awk '/^Import-Package$/ {getline;ok=1} /^[^ ]/ {ok=0} \
{if (ok) print $1}' | sort -u
It uses bnd to print a summary of each jEdit bundle, extracts the package names from
the Import-Package part of the summary, and sorts them into a unique list. (You
could also use the bnd print -uses command to get a tabular view of what packages
use other packages.) After you remove the JDK and OSG i framework packages, you get
the following:
bsh
com.microstar.xml
gnu.regexp
org.gjt.sp.jedit
org.gjt.sp.jedit.browser
org.gjt.sp.jedit.buffer
org.gjt.sp.jedit.gui
org.gjt.sp.jedit.help
org.gjt.sp.jedit.io
org.gjt.sp.jedit.menu
org.gjt.sp.jedit.msg
org.gjt.sp.jedit.options
org.gjt.sp.jedit.pluginmgr
org.gjt.sp.jedit.search
org.gjt.sp.jedit.syntax
org.gjt.sp.jedit.textarea
org.gjt.sp.util
The first group includes third-party packages, next is the main jEdit package, and the
long group contains other jEdit packages.
It's clear that the third-party library bundle needs to export only three packages
and the main jEdit bundle just the top-level package. Unfortunately, the jEdit engine
bundle needs to export almost all of its packages, indicating a tight coupling between
the engine and the top-level jEdit package. This suggests that it would be better to
merge these two bundles back together, unless you were going to refactor the code to
reduce this coupling. Let's ignore this for now and press on, because this separation
will eventually lead to an interesting class-loading issue that's worth knowing about.
Anyone who's curious can skip ahead to section 6.2.4.
What's next on the JAR -to-bundle checklist? Ah, yes: versioning. You should version
all the exported jEdit packages with the current bundle version (4.2); but you won't ver-
sion the individual third-party packages at the moment, because it's not obvious what
releases are being used. You can always add the appropriate versions in the future, when
you divide the combined third-party bundle into separate library bundles.
You should also add version ranges to your imports, as suggested back in sec-
tion 6.1.3. Rather than endure the hassle of explicitly writing out all the ranges, you
can take advantage of another bnd feature and compute them:
-versionpolicy: [${version;==;${@}},${version;+;${@}})
Search WWH ::




Custom Search