JBoss Fuse - Apache Karaf



In this chapter, we will discuss about Apache Karaf and why it is called as a lightweight OSGi Container along with its benefits and other important features.

The JVM Problem

JVM or Java virtual Machine does not act as an actual virtual machine. A machine which will allow you to stop, start or restart components running inside it on the fly. It may sometimes allow hot deployments at class level but there is no way you could deploy or undeploy a component of your application in your virtual machine without restarting it.

To solve this problem and allow modularity in Java application, Fuse uses an OSGi based runtime known as Apache Karaf.

OSGi

The OSGi technology is a set of specifications that define a dynamic component system for java. These specifications allow a development model where applications are (dynamically) composed of many different (reusable) components.

Benefits of OSGi

  • Reduced Complexity − Application is built as collaborating components which hide their implementation details from each other resulting in reduced complexity.

  • Reusability − Many components can leverage same component deployed in a container.

  • Deployment − OSGi provides support for start, stop and update of components on the fly with its lifecycle management APIs without container restart.

Bundles Vs Features

Following is the comparison between Bundles and Features.

Bundles

Bundles are equivalent to OSGi what jars are to JVM. Bundles are artifacts which are deployable in an OSGi container. The bundles are components which work together or independently to form an application.

These bundles can be installed, uninstalled, updated, started or stopped at runtime without restarting the container.

Features

Features are a way of deploying multiple bundles together. Sometimes it makes more sense to deploy bundles in group. Features allow us to deploy a group of bundles with just one command.

Why another Container?

Apache Karaf is an OSGi based runtime, it is where our Application bundles run. Fuse uses Apache Karaf as its runtime in which bundles run and collaborate to provide business functionality.

Karaf is built on Felix and equinox which are OSGi Frameworks.

Karaf Architecture

Karaf Architecture

Apache Karaf adds the following additional functionalities to basic OSGi runtime.

Hot Deployment

Karaf supports hot deployment. It contains a hot deploy directory. Anything that is placed in this directory is automatically deployed and installed in Karaf as a bundle.

Logging

Karaf provides centralized logging by generating logs for all bundles in $Fuse_home/data/log. We can edit logger configuration in org.ops4j.pax.logging.cfg in $Fuse_home/etc directory.

Admin console

Karaf provides a sophisticated and lucid Admin console to interact with running instance of fuse. It also provides a pre-installed set of commands which can be used to manage and monitor components (Bundle) at runtime. This console is extensible so it allows us to add new commands to the console by adding new bundles to console.

Admin console

SSH Access

Karaf allows remote access to this Admin console with SSH. Anyone with valid credentials can connect to karaf admin console over SSH terminal.

Advertisements