Time for action - installing and testing the service

At this stage, we have the following bundles installed:

g! lb
START LEVEL 2
ID|State |Level|Name
0|Active | 0|System Bundle (3.0.1)
1|Active | 1|Apache Felix Bundle Repository (1.6.2)
2|Active | 1|Apache Felix Gogo Command (0.6.0)
3|Active | 1|Apache Felix Gogo Runtime (0.6.0)
4|Active | 1|Apache Felix Gogo Shell (0.6.0)
5|Active | 2|Bookshelf Inventory API (1.4.0)

6|Active | 2|Bookshelf Inventory Impl - Mock (1.4.0)

And the following repositories registered with the OBR service:

g! repos list
file:/C:/projects/felixbook/releases/repository.xml

http://felix.apache.org/obr/releases.xml

We refresh our releases repository and get the updated list of Bookshelf bundles:

g! repos refresh file:///C:/projects/felixbook/releases/repository.xml
g! list book
Bookshelf Inventory API (1.5.0)
Bookshelf Inventory Impl - Mock (1.5.0)

Bookshelf Service (1.7.0)

Notice that the bundle we've just deployed now appears on the list. We will download, install, and start the bookshelf service bundle using the obr deploy command.

But before doing that— for the fun of seeing things break, let's stop the book inventory implementation.

g! stop 6
Stoping Book Inventory Mock Impl

This will make the inventory functionality unavailable when the bookshelf service activator tries to run the tests.

Now, let's instruct the OBR service to deploy and start the bookshelf service. We're installing the bookshelf service on start level 3 (Tier 2 services):

g! bundlelevel -i 3
g! frameworklevel 3
g! deploy -s "Bookshelf Service"
Target resource(s):
-------------------
Bookshelf Service (1.7.0)

Deploying...

Having checked dependencies, it installs the service and attempts to start it. However, when we start with our test, we attempt to get an instance of the BookInventory service— in lookupBookInventory()— and this bit fails (I've reformatted the output and hidden most of the stack trace for clarity):

Signing in. . .
Adding books. . .
ERROR: Resolver: Start error -
com.packtpub.felix.bookshelf-service
org.osgi.framework.BundleException:
Activator start error in bundle
com.packtpub.felix.bookshelf-service [8].
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1909)
at ...
Caused by: com.packtpub.felix.bookshelf.service.impl.BookInventoryNotRegisteredRuntimeException:
BookInventory not registered, looking under:
com.packtpub.felix.bookshelf.inventory.api.BookInventory
at com.packtpub.felix.bookshelf.service.impl.-
BookshelfServiceImpl.lookupBookInventory(
BookshelfServiceImpl.java:53)
at ...

done.

We'll get to fix this later. Let's take a closer look at the first bit of the start operation.

What just happened?

As the bookshelf-service bundle is started, the activator is invoked. It registers the BookshelfServiceImpl under the class name BookshelfService (fully qualified). It then kicks off the test operations.

Then the activator requests an implementation of the inventory service API from the framework. In regular situations, this would provide it with one. However, none is available on the framework (because we've stopped it).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.198.94