Discussion:
dynamic module load/unload
(too old to reply)
Michał Zegan
2018-10-21 12:08:55 UTC
Permalink
Hello.
There are existing systems like jboss-modules and osgi and they do
cooperate/will cooperate? with jpms... However if I want to create a new
application and prefer a jpms native approach, what do I need to achieve
fully dynamic load and unload of modules or some bigger collections of
modules?
I know that the jpms is mostly static with the exception being that you
can create module layers and put modules there, but in order to use that
for apps a thin layer above jpms may probably be needed?
What I think about, when my application wants to load a module/set of
modules, it would need to, assuming one layer is one module:
- have a module finder finding all modules (probably the
ModuleFinder.of() could be of use, maybe even ModuleFinder.ofSystem()),
- when loading module a, the module descriptor needs to be opened and
all direct requirements scanned, then if some required module is not yet
loaded, it should be loaded (as all of them should land in separate layers),
- the to be loaded module needs to be resolved by creating a
configuration, probably against all configurations of all layers of all
currently loaded modules put in load order, with boot layer prepended,
the module finder would be used as an afterfinder,
- the module layer would be created based on this new configuration, and
using respective layers of parent configurations, and the layer
reference should be saved in a module list.
- unloading a module, after it is not used, would just mean removing it
from the list, it would be unloaded if nothing depends on it.
Is that correct in any way? I know that what I am talking about does not
probably include service binding and doesn't really solve multiple
versions of the same module loaded at the same time. Although that way
dependencies are mostly handled by jpms, the app code just scans direct
dependencies to have a chance to create dependent modules in separate
layers as opposed to loading it in same layer as the initial module that
was requested.
Alex Sviridov
2018-10-22 12:15:49 UTC
Permalink
Hi Micha,

See here : https://stackoverflow.com/questions/46112809/is-it-possible-to-load-and-unload-jdk-and-cust
Loading...