Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why osgi is used?

Tags:

I want to know why OSGI framework is used when building java applications. I am searching the web for this but answers look complex to me. Can anyone please explain few points on why we need to adopt osgi.

Am sorry if the question does not suit stackoverflow I appreciate the patience of the readers. Thanks.

like image 433
javalearner Avatar asked Dec 06 '11 08:12

javalearner


People also ask

What is OSGi framework?

OSGi defines a dynamic module system for Java™. The OSGi service platform has a layered architecture, and is designed to run on various standard Java profiles. OSGi Applications deployed to WebSphere® Application Server run on an Enterprise Java profile that is provided as part of the server runtime environment.

Is OSGi a Microservice?

OSGI is an application architecture, while microservices is a distributed systems concept. In my experience, microservices offer a number of benefits: Individual microservices are easy to deploy, test, and maintain. Microservices are language agnostic.

Is OSGi a dependency injection?

As an improvement over dependency injection with Spring, OSGi Declarative Services supports dynamic dependency injection. You can create and publish service components for other classes to use. You can update the components and even publish alternative component implementations for a service.

What is a OSGi bundle?

OSGi is a Java framework for developing and deploying modular software programs and libraries. Each bundle is a tightly coupled, dynamically loadable collection of classes, jars, and configuration files that explicitly declare their external dependencies (if any).


2 Answers

OSGi provides a modular system with versioning of the modules, and further a bit of life cycle management. It manages dependencies between modules, dynamic/lazy startup/uninstall of modules, lookup/discovery and such.

Part of this will become part of the java language. It enables a lesser complexity than a spaghetti wiring of classes.

like image 135
Joop Eggen Avatar answered Oct 07 '22 08:10

Joop Eggen


IMHO OSGI on its own requires a a lot of boiler plate code for what it does. However if you use a library like Karaf & iPOJO most of the overhead is hidden and you get most of the benefits.

The main benefit is being able to control which versions are used and proper module isolation. For example you can

  • have the container download the right versions from a maven repository like nexus.
  • use multiple version of the same library and have the modules which need those use the right ones.
  • stop, upgrade and start modules while the application is running.
  • a web console to see the state of all your modules and manage them collectively or individually.
like image 45
Peter Lawrey Avatar answered Oct 07 '22 08:10

Peter Lawrey