3.3 A guide to forming bundles
Prev | 3. Deployment Architecture | Next

## 3.3 A guide to forming bundles

So what makes a good application suitable for deployment on the Virgo Web Server? Since OSGi is at the heart of the VWS, modular applications consisting of bundles, which each represent distinct functionality and well-defined boundaries, can take maximum advantage of the OSGi container’s capabilities. The core ideas behind forming bundles require following good software engineering practices: separation of concerns, minimum coupling, and communication through clear interfaces. In this section, we look at a few approaches that you may use to create modular applications for Virgo Web Server deployment. Please consider the following discussion as guidelines and not as rules.

Bundles can be formed along horizontal slices of layering and vertical slices of function. The objective is to enable independent development of each bundle and minimize the skills required to develop each bundle.

For example, an application could have the following bundles: infrastructure, domain, repository, service, and web as shown in the following diagram.

Each bundle consists of types appropriate for that layer and exports packages and services to be used by other layers. Let’s examine each bundle in more detail:

Table 3.2. Bundles across layers

Bundles | Imported Packages | Exported Packages | Consumed Services | Published Services
--- | --- | --- | --- | ---
Infrastructure | Third-party libraries | Infrastructure interfaces | None | None
Domain | Depends: for example, if JPA is used to annotate persistent types, then JPA packages. | Public domain types | None | None
Web | Domain, Service | None | Service beans | None
Service | Domain, Infrastructure, Repository | Service interfaces | Repository beans | Service beans
Repository | Domain, Third-party libraries, ORM bundles, etc. | Repository interfaces | DataSources, ORM session/entity managers, etc. | Repository beans

Within each layer, you may create bundles for each subsystem representing a vertical slice of business functionality. For example, as shown in the following figure, the service layer is divided into two bundles each representing separate business functionalities.

You can similarly separate the repositories, domain classes, and web controllers based on the business role they play.

Prev | Up | Next
3.2 Dependency Types | Home | 4. Developing Applications