Java Reference
In-Depth Information
of the package that includes a modified Message interface. You may
wonder what this package is doing in your spoke bundle—maybe you're experiment-
ing with a new design, or perhaps it was included by mistake. How it got there isn't
important. What is important is that you have a 2.0 version of floating
around without a corresponding 2.0 version of the Spoke Service Provider Interface
( SPI ). Let's see how this affects the package wiring.
The hub extender and test bundles still have the original, restricted version range:
They get Spoke and Message from the original API bundle, but your spoke bundle has
This means it gets the original Spoke interface from the API bundle and the updated
Message from itself. (Remember, the framework always tries to pick the newest version
it can.) Thus the Spoke interface and your implementation see different versions of
the Message interface, which causes the LinkageError in the JVM . Figure 8.12 shows
the mismatched wiring.
You must tell the framework that the various hub packages are related, so it can
stop this mismatch from happening. This is where the missing uses constraints come
in. Edit the chapter08/classloading/ file and remove
this line from the bnd instructions:
-nouses: ${no.uses}
Removing this re-enables bnd support for uses constraints. If you run the example
$ ./chapter08/classloading/PICK_EXAMPLE 4 1.0 1.0 2.0
Spoke 1.0 1.0 1.0 2.0
Figure 8.12 Mismatched wiring due to missing uses constraints
Search WWH ::

Custom Search