Java Reference
In-Depth Information
Figure 13.9
If you install the
fancyfoods.department.chocolate
bundle before the
fancyfoods.api
bundle, the chocolate bundle can't be resolved. Exploring the snapshotted OSGi state
shows the reason for the resolution failure.
13.6
GlassFish
Although Virgo is a well-established alternative to Apache Aries, there are several
other independent enterprise
OSG
i implementations. Since version 3, GlassFish ships
with enterprise
OSG
i support. The support available in version 3 was mostly limited to
web applications, but much more complete support, including
JPA
,
JTA
, and
EJB
inte-
gration, shipped in version 3.1. GlassFish has coined the term
hybrid applications
to
describe applications that combine the modularity of
OSG
i with the ability to take
advantage of Java
EE
infrastructure. The hybrid application programming model is
the enterprise
OSG
i programming model, but we think the phrase nicely captures the
ideas behind enterprise
OSG
i.
13.6.1
Dependency injection
Uniquely among the servers in this chapter, GlassFish doesn't include a Blueprint
implementation. The assumption is that users will use Java
EE
's
CDI
(Contexts and
Dependency Injection) for inversion of control. In its base form,
CDI
has no aware-
ness of OSGi, but GlassFish has extended it with an
@OSGiService
annotation that
allows services to be injected. This approach has the advantage of being annotation-
based, which allows dependencies to be injected concisely. It will also feel natural if
you're already used to using
CDI
. But because it's not standards-based, applications
written for the GlassFish
CDI
won't be portable to other application servers.
