Java Reference
In-Depth Information
If you're planning to use both bnd and Declarative Services, you may find the bnd
support for Declarative Services handy. Service components can be declared within
bnd files; bnd will generate the component XML files. The bnd format for service
components is another syntax to learn, but it's more concise than the XML .
For example, the cheese bundle can be packaged so that it uses bnd Declarative
Services instead of Blueprint, with the following bnd file. (We've switched from the
persistence bundle to the cheese department bundle, both for variety, and because
you can't do the sort of container-managed JPA Blueprint made possible with Declara-
tive Services.)
-include= ~../common.props
Bundle-SymbolicName: fancyfoods.department.cheese
Private-Package: fancyfoods.dept.cheese*
Service-Component=fancyfoods.cheese.offer; \
enabled:=true; \
If you drop the rebuilt cheese bundle into your Aries assembly's load directory in
place of the original cheese bundle, you should find everything works exactly as
before. The cheese offer gets to the Service Registry by a different mechanism, but the
service is the same. (Don't forget, you'll need to add a Declarative Services implemen-
tation to your Aries assembly.)
Just as there's more to bnd files than generating better manifests, there's more to
bnd than building. Bnd is also useful for working with existing conventional JAR s and
bundles. You'll see more about these parts of bnd in section 12.1.3.
Although bnd on its own is useful, its mechanisms for specifying classpaths and
build paths are fairly limited. Some large projects build with bnd alone, but most opt
to use one of the bnd integrations with more general build tools. The bnd project
provides Ant tasks, and it's also extremely well integrated with Maven through the
bundle plug-in.
The Maven bundle plug-in
Maven considerably simplifies the dependency management required when building
with Ant. If Maven is your build tool of choice, you'll find that the decision about
whether to control your manifests directly or generate manifests automatically has
been mostly made for you. Although it's technically possible to use Maven to build
bundles while using existing manifests—and the sample code for the earlier chapters
of this topic did that—it's not a natural way of using Maven. (If you need convincing,
you need only to look at the build scripts packaged with the sample code!)
In many ways, Maven is a natural fit with OSG i, because Maven's modules and
dependencies map relatively neatly to OSG i bundles. Both modules and bundles are
Search WWH ::

Custom Search