Chapter 3. Creating the First OSGi Application

Throughout the rest of this book, we will build a simple, conference-scheduling application as an example. Along the way, we will add a NoSQL datastore, create RESTful web services, and deploy it to the cloud. Because long code listings in a book don’t read very well, we keep all code examples short. You can download the full source code from GitHub.

In this chapter, we will create the following parts of the application:

  • An API bundle containing our domain classes and service API
  • An OSGi service
  • A Gogo shell command that uses our service

Figure 3-1 depicts the application as a set of bundles. By developing it this way, you will get some hands-on experience with creating bundles, package imports, and exports; creating services; and running applications from Bndtools.

Overview of the agenda application

Figure 3-1. Overview of the agenda application

Prerequisites

Before you get started, make sure you have all prerequisites installed:

  • A Java Development Kit (JDK 7 or higher).
  • Eclipse, with the Bndtools plug-in installed. The book examples are written using Bndtools 2.x. Bndtools can be installed from the Eclipse Marketplace.

Getting Started

After installing and starting Eclipse, let’s start working on the example application by creating a new project using the Eclipse Bndtools plug-in. Start with an empty workspace, and create a new Bndtools OSGi project. The project name should ...

Get Building Modular Cloud Apps with OSGi now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.