Chapter 5. Introduction to OSGi
Abstract
The OSGi specification supports modular application development by defining a runtime framework that simplifies building, deploying, and managing complex applications.
5.1. Red Hat JBoss Fuse
Overview
Red Hat JBoss Fuse has the following layered architecture:
- Technology layer—includes technologies such as JBI, JAX-WS, JAX-RS, JMS, Spring, and JEE
- the section called “Red Hat JBoss Fuse” —a wrapper layer around the OSGi container implementation, which provides support for deploying the OSGi container as a runtime server. Runtime features provided by the Red Hat JBoss Fuse include hot deployment, management, and administration features.
- OSGi framework —implements OSGi functionality, including managing dependencies and bundle lifecycles
Red Hat JBoss Fuse
Figure 5.1 shows the architecture of Red Hat JBoss Fuse.
Figure 5.1. Red Hat JBoss Fuse Architecture
Red Hat JBoss Fuse is based on Apache Karaf, a powerful, lightweight, OSGi-based runtime container for deploying and managing bundles to facilitate componentization of applications. Red Hat JBoss Fuse also provides native OS integration and can be integrated into the operating system as a service so that the lifecycle is bound to the operating system.
As shown in Figure 5.1, Red Hat JBoss Fuse extends the OSGi layers with:
- Console— an extensible Gogo console manages services, installs and manages applications and libraries, and interacts with the Red Hat JBoss Fuse runtime. It provides console commands to administer instances of Red Hat JBoss Fuse. See the "Console Reference".
- Logging—a powerful, unified logging subsystem provides console commands to display, view and change log levels. See "Configuring and Running Red Hat JBoss Fuse".
- Deployment—supports both manual deployment of OSGi bundles using the
osgi:install
andosgi:start
commands and hot deployment of applications. When a JAR file, WAR file, FAB file, or OSGi bundle is copied into the hot deployment folder InstallDir/deploy
, it's automatically installed on-the-fly inside the Red Hat JBoss Fuse runtime. When you update or delete these files or bundles, the changes are made automatically. See Section 7.1, “Hot Deployment”. - Fuse Application Bundle (FAB)—FABs automate the creation and maintenance of OSGi bundles, freeing application developers to focus on building their applications. See Part III, “The Fuse Application Bundle Deployment Model”.
- Provisioning—provides multiple mechanisms for installing applications and libraries. See Chapter 8, Deploying Features.
- Configuration—the properties files stored in the InstallDir
/etc
folder are continuously monitored, and changes to them are automatically propagated to the relevant services at configurable intervals. - Spring DM—simplifies building Spring applications that run in an OSGi framework. When a Spring configuration file is copied to the hot deployment folder, Red Hat JBoss Fuse generates and OSGi bundle on-the-fly and instantiates the Spring application context.
- Blueprint—is essentially a standardized version of Spring DM. It is a dependency injection framework that simplifies interaction with the OSGi container—for example, providing standard XML elements to import and export OSGi services.