Chapter 2. Developing a simple OSGi-based web application
This chapter covers
- Setting up an enterprise OSGi container
- Developing a simple OSGi-based web application
- Wiring components together with Blueprint
- Using JNDI to integrate enterprise OSGi and Java EE code
The web is one of the most fundamental parts of enterprise Java programming, providing a frontend for almost every enterprise application. At the end of the chapter 1, we mentioned that a trivial Hello World application didn’t make much sense when we were talking about enterprise OSGi, because enterprise applications are by definition nontrivial. But that doesn’t mean that writing them has to be complicated or difficult! In this chapter, we’ll get you going with a simple web application, and then we’ll move on to discuss the essential glue of enterprise OSGi: Blueprint dependency injection. Think of it as Hello World Wide Web.
We’re sure you’re eager to get going playing with real code, so we’ll begin by introducing our sample application and letting you get your hands dirty with a handy development sandbox.
In the succeeding chapters, we’ll build up a small sample enterprise application, the Fancy Foods web store. By the end of the book, the Fancy Foods application will have a web frontend, a database backend, and transactional purchasing. Its modules will be wired to one another using dependency injection, and packaged together as an installable archive.