Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

some doubts related to osgi

I am new to OSGI framework. I was going through the sites and read about OSGI framework. Frankly speaking I did notunderstand anything. Following are my doubts

  1. OSGi is supposed to provide modularity. Cant we achieve the modularity through normal jars?
  2. What does it mean that OSGi has a dynamic component model?
  3. Bundles can be installed,started,stopped,updated,etc. Why do we want to install the bundles? Why cant we access directly like what we access other normal jars?

I am totally confused. Can somebody answer me ? If it is possible to give some examples also.

like image 651
user414967 Avatar asked Dec 08 '22 21:12

user414967


2 Answers

  1. No. JARs are open containers for classes and provide no runtime encapsulation. See http://www.slideshare.net/bjhargrave/why-osgi
  2. Dynamic means that a bundle's lifecycle can be altered while the VM/OSGi framework is running. That is, you don't need to restart the system to install/start/stop/update/uninstall a bundle.
  3. You want to do those things to manage the lifecycle of the bundles. One does not have to use OSGi in a dynamic way. You can just use it for modularity and services while only installing the bundles up front before starting the framework.
like image 191
BJ Hargrave Avatar answered Dec 25 '22 09:12

BJ Hargrave


My definition of a module is a unit of encapsulation (i.e. it hides internal details) that communicates with other modules via a contract (i.e. a predefined set of possible interactions). A JAR file is not a module because it exhibits neither of these properties. There is no encapsulation, all internal implementation details are visible and accessible from the outside. There is no contract, you just put the JAR file on the classpath and hope it provides the features you desire.

Dynamic means that OSGi bundles (modules) can be installed, upgraded or uninstalled during runtime. This can be very useful for upgrading running systems or for deploying software to a efficiently across a large network.

Bundles have to be installed because software always has to be installed before we use it. JAR files also have to be installed! Only the means of installation is slightly different, i.e. JAR files are added to the classpath whereas bundles are installed using the install command (this can also be scripted or called from an API). OSGi gives us much more control over this process.

like image 26
Neil Bartlett Avatar answered Dec 25 '22 08:12

Neil Bartlett