Java Reference
In-Depth Information
Karaf has a lot of support for Apache Aries, which makes it a convenient environ-
ment for developing and testing enterprise OSG i applications. So well integrated is
Karaf with Aries, Karaf comes with Blueprint support by default. Even better, if you list
the OSG i bundles using the osgi:list , there's a special column that shows each bun-
dle's Blueprint status.
Hot deployment
Like the little Aries assembly we've been using, Karaf can install bundles from the file-
system dynamically. Karaf monitors the ${karaf.home}/deploy directory, and will
silently install any bundles (or feature definitions) dropped into it. To confirm which
bundles are installed and see their status, you can use the list command.
Karaf features
Karaf features, like Pax Runner profiles, are precanned groups of bundles that can
easily be installed. As an added bonus, Karaf features have been written for many of
the Apache Aries components. To see all the available features, type features:list .
To install new features, type features:install -v (the -v option does a verbose
install). To get a working Apache Aries runtime with Karaf features, it's sufficient to
execute the following commands:
features:install -v war
features:install -v jpa
features:install -v transaction
features:install -v jndi
You'll also need to enable the HTTP server by creating a file called ${karaf.home}/etc/
org.ops4j.pax.web.cfg and specifying an HTTP port:
org.osgi.service.http.port=8080
To get the Fancy Foods application going, the final step is to install a database by copying
one into the deploy directory, and then copy your Fancy Foods JAR s into the deploy
directory. You can also install the bundles from the console using Maven coordinates.
The Karaf console is nice, but it doesn't lend itself so well to automation. Luckily,
repositories can be defined, features installed, and bundles started, by changing files
in ${karaf.home}. If you're keen to automate, the Karaf console can even be driven
programmatically.
8.4
Collecting coverage data
When you're running tests against your application, how do you measure the effec-
tiveness of your tests? How do you make sure you haven't forgotten anything? Code
coverage tools instrument your application classes to produce reports on which code
was exercised. We feel collecting coverage data should be an integral part of your
development and testing process.
The good news is that a range of coverage tools are available. Most either make
Ant tasks available or integrate neatly into Maven. The bad news is that instrumenting
classes is different in an OSG i environment, so most coverage tools will spectacularly
fail to work out of the box.
Search WWH ::




Custom Search