The Book Inventory interface will define the Book's storage and look-up functionality for the bookshelf. It will be the contract that a bundle providing book inventory functionality must follow.
The interface is designed to allow many possible implementations of the location where the data is persisted. The goal is to be able to quickly write an implementation that only stores the books in memory (non-persistent when the bundle is stopped); then later replaces it with one that stores the data to a file or to a database.
In this chapter, we will define the Book Inventory API and write a mock implementation. The mock implementation will store the Book items in memory. We will also start looking at how bundles are packaged for installation onto an OSGi framework.
We will:
Then we will:
So let's start with the first bundle, namely, the book inventory API bundle.
The accompanying code for this book can be downloaded from:
http://www.packtpub.com/files/code/1384_Code.zip
By now, you should have gone through the environment setup. If you've just been reading through so far, it's a good idea to go back to Chapter 2, Setting up the environment, and set yourself up for starting the project development.
We'll set up the skeleton of our first bundle, to which we'll add the interface definitions through this chapter.
Here, we will go through the manual steps for the setup of a bundle— it's always good to know how to do things without the assistance of tools. Appendix A, Eclipse, Maven, and Felix, guides you through the steps to automate a lot of the following topics for the same outcome using Eclipse and its plugins.