Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does OSGi application work on Java 9?

Tags:

java

java-9

osgi

I am trying to understand how OSGi application works in Java 9 assuming that OSGi bundle is not JPMS module (as far as I know there is still no solution that OSGi bundle could be at the same time JPMS module for production). And I have several questions:

  1. Do I understand right that all OSGi application will be one unnamed module?
  2. If #1 yes, then how does Bundle.update() works? Is bundle reloaded to unnamed module?

If I understand everything wrong, please explain main principles.

like image 817
Pavel_K Avatar asked Sep 17 '17 11:09

Pavel_K


People also ask

How does OSGi framework work?

How does OSGi work? OSGi is a set of specifications that define a dynamic component system for Java. These specifications allow for a development model in which an application is composed of several components, and then packed into bundles. These components communicate locally and through the network via services.

What is an OSGi application?

The OSGi (Open Service Gateway Initiative) specification is a Java framework for developing and deploying modular software programs and libraries. The framework was originally managed by the OSGi Alliance, an open standards organization.

What is the point of OSGi?

What is OSGi? OSGi is meant to solve common class loading issues that are seen in traditional Java EE environments; it is a set of specifications that are used in the creation of jars with extra manifest information to define dependencies and class loading behavior.

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.


1 Answers

Java SE 9 guarantees continued compatibility for all applications and libraries that stick to the standard Java SE libraries.

OSGi only uses published Java SE APIs and therefore will continue to work unchanged on Java 9. It does not at this time interact with JPMS modules, which will be the case for all your other Java software. At some point the OSGi expert groups will likely produce a specification for interoperability between JPMS modules and OSGi bundles, but that is for the future.

To answer your specific questions:

  1. Yes, OSGi bundles will be mapped to one or more "unnamed" modules in JPMS terms. Again, this is exactly how Java 9 retains backwards compatibility for all your other Java applications.

  2. Bundle update works the same way it has worked for 18 years. The classloader provided for the bundle is disposed and a new classloader created to load the updates classes.

like image 153
Neil Bartlett Avatar answered Oct 23 '22 09:10

Neil Bartlett