This OSGi project shows how an unmodular (monolithic, one-bundle) OSGi project is transformed into a modular, flexible one in two steps. In all variants, it implements a simple web service for searching one or more dictionaries.
This OSGi project shows how an unmodular (monolithic, one-bundle) OSGi project is transformed into a modular, flexible one, in two steps. All three variants implements a simple web service for searching one or more dictionaries. Logically, all variants consist of a domain part, the dictionary- and search-related classes (among others, a **Dict** interface and its implementations) and the web service (a **Servlet**). Technically, the variants differ in how these parts are distributed among bundles and utilize the component mechanism.
## Setup
The root project and folder was created using the BndTools' Bnd OSGi Workspace wizard, and each bundle with the Bnd OSGi Project wizard. Which bundle template to use depends on the specific bundle, there are api, component and servlet bundles in this project.
## Variant 1
The first variant consists of the [tdt4250.dict1.servlet](../tdt4250.dict1.servlet/README.md) bundle, which was created using Bnd OSGi Project wizard and the Servlet Component template. It contains both the logic for dictionary search and the **Servlet**, i.e. it is unmodular. It's also inflexible, since the set of dictionaries is hard-coded into the **Servlet** implementation class.
The first variant consists of the [tdt4250.dict1.servlet](../tdt4250.dict1.servlet/README.md) bundle, which was created using the Servlet Component template. It contains both the logic for dictionary search and the **Servlet**, i.e. it is unmodular. It's also inflexible, since the set of dictionaries is hard-coded into the **Servlet** implementation class.