Java Reference
In-Depth Information
WARNING: THE IMPACT OF ONE MISSING SERVICE If any service dependency of
a bundle can't be satisfied, the Blueprint container won't start. This can be
hard to spot, because the bundle itself will reach the started state. No Blue-
print container means no Blueprint services at all will be registered by that
bundle, and there will be no managed Blueprint beans for the bundle. You
may not have expected that a missing service dependency for one bean would
prevent all your other beans from running. If you're hitting problems in this
area, consider declaring some of your service dependencies optional (see sec-
tion 6.4.2) or dividing your bundle into smaller independent bundles. If you
have several independent dependency networks in the same bundle, it may
be a sign that you haven't got the modularity right.
Blueprint also has an elegant way of handling services that appear, disappear, or change
at runtime. Like the grace period, it's a sophisticated variant of container-managed wait
and hope . It's a lot more robust than this description makes it sound, and it's also more
granular than the startup case. This is known as damping.
DAMPING
OSG i Blueprint aims to reduce the complexity of consuming OSG i services by per-
forming service damping —rather than injecting a managed bean with a service, the
Blueprint container injects a proxy. This means that if the service implementation
needs to be replaced, then this can be performed transparently, without interrupting
the normal operation of the bean. Figure 6.7 shows how a proxy allows the provider to
be transparently swapped.
If no other implementation is available, any services registered by the consuming
bean will automatically be unregistered. This management of dependency chains is
one of the benefits of using Blueprint. You can see this behavior in action in the Fancy
Foods application by stopping the persistence bundle. The Blueprint container will
automatically unregister the desperate cheese special offer, because that special offer
required the persistence service (see figure 6.8).
The offer aggregator uses a reference list rather than a single reference. The
cheese service is transparently removed from the aggregator list when it's unregis-
tered, and the aggregator service itself isn't affected.
Delegate
Client
Provider 1
Proxy
Provider 2
Figure 6.7 If the proxied implementation of a Blueprint-provided service becomes unavailable, the
proxy will be transparently wired to another implementation.
Search WWH ::




Custom Search