OSGi is a standard that defining Dynamic Component Development
for Java.
Its specification that define the API to develop dynamic
components in java application development. As per OSGi application composed of
several components and components are packaged as bundle.
Java to build complex application is big challenge where
OSGi defining way to divide application into several bundles and each bundle
composed with several components.
OSGi is providing environment where all these bundles
and components can communicate each other such way we can run complex
application.
Component:
Component is small unit of application and it called
as some feature in the application. Component cam work independently or it can collaborate
with other component to full fill the requirement in the application.
Bundle:
Bundle is composed with several components and OSGi we
package components as bundles and we will deploy bundles into OSGi container.
Services:
Services are part of component and it will full fill
one more tasks. OSGi we can export and import services such as way we can make
available services to other components or bundles.
Modules:
Module is basic terminology in OSGi modular
development and these modularity concept achieved through bundles. Modules and
bundles are same.
OSGi Layers.
OSGi architecture divided into several layers. I have
taken the following picture from enRoute.
Source of image: enroute
Bundles:
Bundles are packaged components developed by OSGi
developers. Bundle is packaged as JAR file and we can deploy into OSGi
containers.
Services:
Services layer provide mechanism to share services
between bundles. It will provide environment to register services and make available
to other bundles. We have concept called publish-find-bind.
We have different framework to achieve this concept. Declarative Services and Apache Service Component Runtime are the
implementation for this concept.
Life
Cycle:
Life Cycle is responsible to manage lifecycle of
bundles. OSGi bundle have several lifecycle stages install, start, update, stop and uninstall. All these stages handles
in this layer.
Module:
Module layer is define the import / export the code of
the bundles. Usually we will use export/import headers in the OSGi manifest
file that will handle in module layer.
Execution
Environment.
Execution Environment layer define the classes and
methods are available to the platform.
Security:
Security layer define standards security to the OSGi
applications. How your modules available to the other platforms and it will define
some permission system.
Java
VM
Java VM layer is provide the JAVA run time environment.
Its basic layer in the OSGi.
Operating
System
It will provide standard Operating System to the OSGi environments.
Deployment
OSGi provide run time container there we can deploy
bundles. Bundles are standard package system where we can package all java
classes and interfaces. Bundle is JAR file. We have different commands provided
by OSGi command line interface to deploy bundles.
Implementation
OSGi specification implemented by several vendors’
popular vendors Equinox and Apache Felix. We can develop OSGi application which
target to anyone of these implementations. Both implementations are followed
the OSGi standard specification. There may be few features vendor specific but
most of the implementation as per OSGi specification.
Reference:
Author