What is OSGi and what are some examples of its use?

I was just starting to hear that the term OSGi was used (when reading textbooks on regular Java EE containers such as GlassFish and Spring), but I could not find a simple, straightforward - simple, understandable explanation that OSGi is what entrepreneurialism understands a beginner like me.

Can anyone provide such fake evidence? Maybe with some examples or even code snippets?

Thank!

+48
terminology osgi
Jan 02 2018-10-14T00:
source share
2 answers

Simply put, OSGi is a dynamic modular system for Java. It defines the means for installing, removing, updating, starting and stopping modules. These modules are called packages, but in their simplest form, they are actually Java jar files with a special manifest. Modules can be installed, removed, etc. Without stopping or restarting the Java virtual machine.

The OSGi framework manages the described life cycle and dependencies between packages in a secure manner. A package should indicate which Java packages it exports and which it imports. Import and export operations can be annotated with version information, so you can even have more than one version of the same package in the same Java virtual machine.

The OSGi Alliance is an organization that defines the OSGi infrastructure and many related services, for example. to manage configuration data, device access, etc.

This is a very simple overview. OSGi is much more. Please see https://www.osgi.org/developer/architecture/ (an introduction to OSGi architecture) and https://www.osgi.org/developer/where-to-start/ (many links and further readings recommended OSGi Alliance).

+60
Jan 03 2018-11-11T00:
source share

Due to some down votes ;-), I would like to answer this in my own words (so that I can correct my understanding).

We create applications as a set of modules, each module is functionally cohesive on its own and loosely connected with other modules. This has many advantages, as you already know. Overtime, the modularity module has improved from functions to classes to packages to deployment units (for example, jar in Java and assemblies in .NET). But all this is only during development, when the application (which is a set of modules) is deployed, the server still sees one gigantic monolithic application in it, that is, the logical boundaries are not preserved at run time. OSGi makes these boundaries explicit during development, as well as at runtime, among other benefits outlined here.

I offer this great free book to get you started with OSGi in practice.

If you are using the Java platform, also check out this presentation: Why are OSGi specifications based on Java ™ technology?

+28
Jan 03 2018-11-11T00:
source share



All Articles