Now that we have seen how to design and build modular applications, we should also know how to actually deploy them to production systems. This book is about building modular cloud apps, so the focus of this chapter will be on deploying to the cloud. We will see, however, that we can use the exact same approach to deploy to in-house servers and even to other types of devices.
So far we have been running our code directly from Bndtools, and we have seen a simple example of launching an OSGi container manually from code. How does this apply to production deployments? First we should understand what an OSGi runtime actually is. An OSGi container is the layer on top of the JVM that understands the concept of bundles and implements all the rules and features defined in the OSGi Core Specification. OSGi containers are in general extremely lightweight and are also often used in environments with very constrained resources. In a pure OSGi environment, you might run a bare-bones OSGi container as your deployment platform directly. This works very well, and we will discuss this extensively in this chapter.
An OSGi container can also be embedded in other kinds of server products such as Java EE application servers or even as part of an application. After discussing our preferred deployment model, we will discuss these alternatives.
In all the examples in the book, we have been using Apache Felix. There ...