OSGI – ABCs

Fuse uses apache karaf as its runtime. Apache karaf is osgi based runtime. So to understand fuse and karaf we need to know what is OSGi

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

If we take any java application it acts as application with monolithic architecture at run-time. It may have well structured package hierarchy inside it to group classes together according to their functionality but it provides convenience at development time. Run-time we cant say like I have now improved some package ABC which results in better performance and have some bug fixes now Application should  be able to use this new implementation. Its not possible in conventional java system cause in normal java environment application is developed as complete package which contains everything it needs and if something changes even some small part of it whole application needs to be recompiled with changes.

The OSGi tries to solve this problem with something called as dynamic component system. OSGi allows us to modularise our application which was not possible in conventional java application.

In OSGi application is composed of various components which work together to achieve business functionality. These components are resolved at run time by each other which allows us to change one component without need of recompiling or changing whole application. This permits us to even better reuse of modules at run-time.

Benefits of OSGi

Reduced COMPLEXITY

Applications are built as collaborating components which hide their implementation details from each other. They communicate with each other using find and bind service module. This allows us to change implementation of one component without breaking dependent components

Re-usability:

Dynamic components approach leads to even better re-usability. Many application can leverage same component deployed in container unlike traditional java environment where each application needed to have its dependency bundled with it or provided by container.

Deployment:

OSGi is not about just development of modular components it also covers installation and management of these components.

Dynamic updates:

OSGi allows components to be started, stopped ,installed ,uninstalled or updated dynamically at run time.

Widely used:

Many well known companies and application use OSGi. Like Eclipse the IDE, Oracles weblogic, IBM websphere, Suns Glassfish and Redhats JBoss EAP

OSGi Architecture

image

Bundles:

Bundles are executable artifacts in OSGi environment .
The bundles are components which work together or independently to form an application. Bundles are unit of execution in OSGi. Its to OSGi what jar is to java (except one jvm runs only one jar separate jar needs separate jvm here OSGi steals the show by allowing multiple bundles to run in same container)

Services:

Each bundle connect with other using OSGi service model. In this model each bundle registers what it wants to offer to out side bundles as service in OSGi service registry. Other bundle now find services they want from OSGi registry and bind to that service to leverage registering bundle.
This allows bundle to hide their implementation details from other bundles making upgrade of one bundle independent of other bundles as bundles are not dependant on other bundles implementation but on services provided by other bundle

Life-cycle API:

This allows us to start ,stop ,install, uninstall or update bundles dynamically

Modules:

A layer which manages how to import and export bundles.

Execution environment:

Defines what classes and method are available in that platform or environment where OSGi container is running.

For more details on OSGi please visit official OSGi site OSGi.org

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s