Java Reference
In-Depth Information
11.2.3
Painting with components
In this chapter and the next, we'll look at three different
OSG
i-based component
frameworks: Declarative Services, Blueprint Container, and i
POJO
. You'll re-create the
example paint program using each of these component frameworks. For each, you'll
have the components shown in figure 11.3, where each component is packaged in its
own bundle (although this isn't strictly necessary).
SimpleShape [0..n]
SimpleShape
Window
Circle
PaintFrame
SimpleShape
Square
Window [1..1]
SimpleShape
WindowListener
Figure 11.3
Components
used in the modified paint
application
Triangle
LogService [0..1]
The
PaintFrame
component provides a
Window
service and has an aggregate depen-
dency on
SimpleShape
services. The shape components each export a single
Simple-
Shape
service, with no service dependencies. The
WindowListener
component has a
mandatory, one-to-one dependency on a
Window
service; it shuts down the framework
when the window it's bound to closes. The
WindowListener
also has an optional, one-
to-one dependency on a
LogService
to log a message when the window is closed.
All versions of the paint program function like the original, but how they achieve
this varies quite a bit. Let's take this high-level of view of
OSG
i-based component
frameworks and make it concrete by turning our attention to the first component
framework on the list: Declarative Services.
11.3
Declarative Services
The Declarative Services specification was defined by the
OSG
i Alliance as part of the
R4 compendium specification. It defines a lightweight approach for managing service
dependencies. The focus of the Declarative Services specification is to address three
main areas of concern, outlined in table 11.2.
The Declarative Services specification addresses these issues by managing service
publication and dependencies for components. Managing service publication on
behalf of components allows Declarative Services to defer service creation and
improve both startup performance and the memory footprint; and managing service