This article is participating in the Java Theme Month – Java Debug Notes Event, see the event link for details

Question: What problem does OSGi solve?

I read about OSGi on Wikipedia and other sites, but I didn’t really get it. They say it’s a component-based platform and you can reload modules at run time. Equally ubiquitous is the “practical example” of the Eclipse plug-in framework.

My question is: what is OSGi in a nutshell?

What common problems does it solve?

By “frequently asked questions” I mean questions we face every day, such as “What can OSGi do to make our work more efficient/fun/easy?”

Answer a

In OSGi, I found the following benefits:

  • Each plug-in is a versioned artifact with its own class loader.

  • Each plug-in depends on the particular JAR it contains and other specific versions of the plug-in.

  • Due to versioning and separate class loaders, different versions of the same artifact can be loaded at the same time. If one component of the application depends on one version of the plug-in and another component depends on another version, they can be loaded simultaneously.

In this way, you can build an application as a set of versioned plug-ins loaded on demand. Each plug-in is a separate component. Just as Maven helps you build your project, which is repeatable and defined by a set of concrete versions of the artifact that created it, OSGi helps you do this at run time.

Answer two

At the very least, OSGi allows you to think about modularity, code reuse, version control, and project exploration in general.

The article translated from Stack Overflow:stackoverflow.com/questions/1…